You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2021/01/30 17:08:55 UTC

[juneau] branch master updated: DTO refactoring.

This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 77e5a46  DTO refactoring.
77e5a46 is described below

commit 77e5a46e2399f4d20684c88cda4876087dba7c06
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Sat Jan 30 12:08:37 2021 -0500

    DTO refactoring.
---
 .../java/org/apache/juneau/dto/LinkString.java     | 118 ++++++++++++++++++---
 .../apache/juneau/dto/swagger/ui/SwaggerUI.java    |   3 +-
 2 files changed, 106 insertions(+), 15 deletions(-)

diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java
index 9456c57..eb40522 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/LinkString.java
@@ -16,6 +16,7 @@ import static org.apache.juneau.internal.StringUtils.*;
 import static org.apache.juneau.internal.ObjectUtils.*;
 
 import java.text.*;
+import java.util.*;
 
 import org.apache.juneau.annotation.*;
 import org.apache.juneau.html.*;
@@ -64,13 +65,17 @@ public class LinkString implements Comparable<LinkString> {
 	// Bean properties
 	//-----------------------------------------------------------------------------------------------------------------
 
+	//-----------------------------------------------------------------------------------------------------------------
+	// name
+	//-----------------------------------------------------------------------------------------------------------------
+
 	/**
 	 * Bean property getter:  <property>name</property>.
 	 *
 	 * <p>
 	 * Corresponds to the text inside of the <xt>&lt;A&gt;</xt> element.
 	 *
-	 * @return The value of the <property>name</property> property on this bean, or <jk>null</jk> if it is not set.
+	 * @return The property value, or <jk>null</jk> if it is not set.
 	 */
 	public String getName() {
 		return name;
@@ -79,21 +84,56 @@ public class LinkString implements Comparable<LinkString> {
 	/**
 	 * Bean property setter:  <property>name</property>.
 	 *
-	 * @param name The new value for the <property>name</property> property on this bean.
+	 * <p>
+	 * Corresponds to the text inside of the <xt>&lt;A&gt;</xt> element.
+	 *
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
+	 */
+	public void setName(String value) {
+		this.name = value;
+	}
+
+	/**
+	 * Bean property fluent getter:  <property>name</property>.
+	 *
+	 * <p>
+	 * Corresponds to the text inside of the <xt>&lt;A&gt;</xt> element.
+	 *
+	 * @return The property value as an {@link Optional}.  Never <jk>null</jk>.
+	 */
+	public Optional<String> name() {
+		return Optional.ofNullable(name);
+	}
+
+	/**
+	 * Bean property fluent setter:  <property>name</property>.
+	 *
+	 * <p>
+	 * Corresponds to the text inside of the <xt>&lt;A&gt;</xt> element.
+	 *
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public LinkString name(String name) {
-		this.name = name;
+	public LinkString name(String value) {
+		setName(value);
 		return this;
 	}
 
+	//-----------------------------------------------------------------------------------------------------------------
+	// uri
+	//-----------------------------------------------------------------------------------------------------------------
+
 	/**
 	 * Bean property getter:  <property>uri</property>.
 	 *
 	 * <p>
 	 * Corresponds to the value of the <xa>href</xa> attribute of the <xt>&lt;A&gt;</xt> element.
 	 *
-	 * @return The value of the <property>href</property> property on this bean, or <jk>null</jk> if it is not set.
+	 * @return The property value, or <jk>null</jk> if it is not set.
 	 */
 	public java.net.URI getUri() {
 		return uri;
@@ -102,35 +142,85 @@ public class LinkString implements Comparable<LinkString> {
 	/**
 	 * Bean property setter:  <property>uri</property>.
 	 *
-	 * @param uri The new value for the <property>href</property> property on this bean.
+	 * <p>
+	 * Corresponds to the value of the <xa>href</xa> attribute of the <xt>&lt;A&gt;</xt> element.
+	 *
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
+	 */
+	public void setUri(java.net.URI value) {
+		this.uri = value;
+	}
+
+	/**
+	 * Bean property fluent getter:  <property>uri</property>.
+	 *
+	 * <p>
+	 * Corresponds to the value of the <xa>href</xa> attribute of the <xt>&lt;A&gt;</xt> element.
+	 *
+	 * @return The property value as an {@link Optional}.  Never <jk>null</jk>.
+	 */
+	public Optional<java.net.URI> uri() {
+		return Optional.ofNullable(uri);
+	}
+
+	/**
+	 * Bean property fluent setter:  <property>uri</property>.
+	 *
+	 * <p>
+	 * Corresponds to the value of the <xa>href</xa> attribute of the <xt>&lt;A&gt;</xt> element.
+	 *
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
 	 * @return This object (for method chaining).
 	 */
-	public LinkString uri(String uri) {
-		uri(uri, new Object[0]);
+	public LinkString uri(java.net.URI value) {
+		setUri(value);
 		return this;
 	}
 
 	/**
-	 * Bean property setter:  <property>uri</property>.
+	 * Bean property fluent setter:  <property>uri</property>.
+	 *
+	 * <p>
+	 * Corresponds to the value of the <xa>href</xa> attribute of the <xt>&lt;A&gt;</xt> element.
+	 *
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
+	 * @return This object (for method chaining).
+	 */
+	public LinkString uri(String value) {
+		uri(value, new Object[0]);
+		return this;
+	}
+
+	/**
+	 * Bean property fluent setter:  <property>uri</property>.
 	 *
 	 * <p>
-	 * Same as {@link #uri(String)} except allows for {@link MessageFormat} style arguments.
+	 * Corresponds to the value of the <xa>href</xa> attribute of the <xt>&lt;A&gt;</xt> element.
 	 *
-	 * @param uri The new href.
-	 * @param args Optional {@link MessageFormat}-style arguments.
+	 * @param value
+	 * 	The new value for this property.
+	 * 	<br>Can be <jk>null</jk> to unset the property.
+	 * @param args {@link MessageFormat}-style arguments in the URL.
 	 * @return This object (for method chaining).
 	 */
-	public LinkString uri(String uri, Object...args) {
+	public LinkString uri(String value, Object...args) {
 		for (int i = 0; i < args.length; i++)
 			try {
 				args[i] = OpenApiSerializer.DEFAULT.createSession().serialize(HttpPartType.PATH, null, args[i]);
 			} catch (SchemaValidationException | SerializeException e) {
 				throw new RuntimeException(e);
 			}
-		this.uri = java.net.URI.create(format(uri, args));
+		this.uri = java.net.URI.create(format(value, args));
 		return this;
 	}
 
+
 	/**
 	 * Returns the name so that the {@link PojoQuery} class can search against it.
 	 */
diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java
index 93cf11f..c29ce57 100644
--- a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java
+++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ui/SwaggerUI.java
@@ -13,6 +13,7 @@
 package org.apache.juneau.dto.swagger.ui;
 
 import static org.apache.juneau.dto.html5.HtmlBuilder.*;
+import static java.util.Collections.*;
 
 import java.util.*;
 import java.util.Map;
@@ -430,7 +431,7 @@ public class SwaggerUI extends PojoSwap<Swagger,Div> {
 		if (s == null)
 			return null;
 		if (s.indexOf(',') == -1)
-			return Collections.<Object>singletonList(s);
+			return singletonList(s);
 		List<Object> l = new ArrayList<>();
 		String[] sa = s.split("\n");
 		for (int i = 0; i < sa.length; i++) {