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/06/06 18:09:22 UTC

[juneau] branch master updated: Code cleanup.

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 a7d0740  Code cleanup.
a7d0740 is described below

commit a7d07401d3d64266789faaf04088188ec24a330a
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Sun Jun 6 14:08:11 2021 -0400

    Code cleanup.
---
 .../main/java/org/apache/juneau/BeanSession.java   | 21 ++++++++++
 .../main/java/org/apache/juneau/ListOperation.java |  9 ++---
 .../org/apache/juneau/httppart/HttpPartSchema.java | 46 ----------------------
 3 files changed, 25 insertions(+), 51 deletions(-)

diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
index 32a7116..98ff9b6 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
@@ -782,6 +782,27 @@ public class BeanSession extends Session {
 	}
 
 	/**
+	 * Wraps an object inside a {@link BeanMap} object (a modifiable {@link Map}).
+	 *
+	 * <p>
+	 * Same as {@link #toBeanMap(Object)} but allows you to specify a property namer instance.
+	 *
+	 * <h5 class='section'>Example:</h5>
+	 * <p class='bcode w800'>
+	 * 	<jc>// Construct a bean map around a bean instance</jc>
+	 * 	BeanMap&lt;Person&gt; bm = BeanContext.<jsf>DEFAULT</jsf>.toBeanMap(<jk>new</jk> Person(), PropertyNamerDLC.<jsf>INSTANCE</jsf>);
+	 * </p>
+	 *
+	 * @param <T> The class of the object being wrapped.
+	 * @param o The object to wrap in a map interface.  Must not be null.
+	 * @param propertyNamer The property namer to use.
+	 * @return The wrapped object.
+	 */
+	public final <T> BeanMap<T> toBeanMap(T o, PropertyNamer propertyNamer) {
+		return this.toBeanMap(o, (Class<T>)o.getClass());
+	}
+
+	/**
 	 * Determines whether the specified object matches the requirements on this context of being a bean.
 	 *
 	 * @param o The object being tested.
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ListOperation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ListOperation.java
index aaf0157..3ccfebc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ListOperation.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ListOperation.java
@@ -43,29 +43,28 @@ public enum ListOperation {
 	/**
 	 * Don't add the value if it's <jk>null</jk> or an empty string.
 	 */
+	@Deprecated
 	SKIP_IF_EMPTY;
 
-	public static final boolean NEEDS_CLEANUP = true;
-
 	/**
 	 * Default flags.
-	 * Needs to be removed.
 	 */
+	@Deprecated
 	public static final EnumSet<ListOperation> DEFAULT_FLAGS = EnumSet.of(APPEND);
 
 	/**
 	 * Default skip-if-empty flags.
-	 * Needs to be removed.
 	 */
+	@Deprecated
 	public static final EnumSet<ListOperation> SKIP_IF_EMPTY_FLAGS = EnumSet.of(APPEND, SKIP_IF_EMPTY);
 
 	/**
 	 * Returns {@link #DEFAULT_FLAGS} if the enum set is <jk>null</jk> or empty.
-	 * Needs to be removed.
 	 *
 	 * @param s The set to check.
 	 * @return Either the same set or {@link #DEFAULT_FLAGS}.  Never <jk>null</jk>.
 	 */
+	@Deprecated
 	public static EnumSet<ListOperation> orDefault(EnumSet<ListOperation> s) {
 		return s == null || s.isEmpty() ? DEFAULT_FLAGS : s;
 	}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index f4410d5..2cbfa30 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -147,7 +147,6 @@ public class HttpPartSchema {
 
 
 	final String name;
-	final Set<Integer> codes;
 	final String _default;
 	final Set<String> _enum;
 	final Map<String,HttpPartSchema> properties;
@@ -643,7 +642,6 @@ public class HttpPartSchema {
 
 	HttpPartSchema(HttpPartSchemaBuilder b) {
 		this.name = b.name;
-		this.codes = copy(b.codes);
 		this._default = b._default;
 		this._enum = copy(b._enum);
 		this.properties = build(b.properties, b.noValidate);
@@ -873,49 +871,6 @@ public class HttpPartSchema {
 	}
 
 	/**
-	 * Returns the HTTP status code or codes defined on a schema.
-	 *
-	 * @return
-	 * 	The list of HTTP status codes.
-	 * 	<br>Never <jk>null</jk>.
-	 * @see HttpPartSchemaBuilder#code(int)
-	 * @see HttpPartSchemaBuilder#codes(int[])
-	 */
-	public Set<Integer> getCodes() {
-		return codes;
-	}
-
-	/**
-	 * Returns the HTTP status code or codes defined on a schema.
-	 *
-	 * @param def The default value if there are no codes defined.
-	 * @return
-	 * 	The list of HTTP status codes.
-	 * 	<br>A singleton set containing the default value if the set is empty.
-	 * 	<br>Never <jk>null</jk>.
-	 * @see HttpPartSchemaBuilder#code(int)
-	 * @see HttpPartSchemaBuilder#codes(int[])
-	 */
-	public Set<Integer> getCodes(Integer def) {
-		return codes.isEmpty() ? Collections.singleton(def) : codes;
-	}
-
-	/**
-	 * Returns the first HTTP status code on a schema.
-	 *
-	 * @param def The default value if there are no codes defined.
-	 * @return
-	 * 	The list of HTTP status codes.
-	 * 	<br>A singleton set containing the default value if the set is empty.
-	 * 	<br>Never <jk>null</jk>.
-	 * @see HttpPartSchemaBuilder#code(int)
-	 * @see HttpPartSchemaBuilder#codes(int[])
-	 */
-	public Integer getCode(Integer def) {
-		return codes.isEmpty() ? def : codes.iterator().next();
-	}
-
-	/**
 	 * Returns the <c>type</c> field of this schema.
 	 *
 	 * @return The <c>type</c> field of this schema, or <jk>null</jk> if not specified.
@@ -1550,7 +1505,6 @@ public class HttpPartSchema {
 				.appendSkipEmpty("name", name)
 				.appendSkipEmpty("type", type)
 				.appendSkipEmpty("format", format)
-				.appendSkipEmpty("codes", codes)
 				.appendSkipEmpty("default", _default)
 				.appendSkipEmpty("enum", _enum)
 				.appendSkipEmpty("properties", properties)