juneau-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] jamesbognar closed pull request #27: Fixed the overview page issue and @Beanconstructor comment issues
Date Wed, 05 Dec 2018 13:55:20 GMT
jamesbognar closed pull request #27: Fixed the overview page issue and @Beanconstructor comment
issues
URL: https://github.com/apache/juneau/pull/27
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConstructor.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConstructor.java
index e990e932a..cded7e1bd 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConstructor.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConstructor.java
@@ -55,9 +55,47 @@
 
 	/**
 	 * The names of the properties of the constructor arguments.
-	 *
 	 * <p>
-	 * The number of properties listed must match the number of arguments in the constructor.
-	 */
+	 *	The {@link org.apache.juneau.annotation.BeanConstructor @BeanConstructor} annotation
is used to 
+	 *	map constructor arguments to property names on bean with read-only properties.
+	 * 	<br>Since method parameter names are lost during compilation, this annotation
essentially redefines 
+	 *	them so that they are available at runtime.
+	 *	</p>
+	 * 	<p>
+	 *	The definition of a read-only bean is a bean with properties with only getters, like
shown below:
+	 *	</p>	
+	 *	<p class='bpcode w800'>
+	 *		<jc>// Our read-only bean.</jc>
+	 *		<jk>public class</jk> Person {
+	 *			<jk>private final</jk> String <jf>name</jf>;
+	 *			<jk>private final int</jk> <jf>age</jf>;
+	 *
+	 *			<ja>@BeanConstructor</ja>(properties=<js>"name,age"</js>)
+	 *			<jk>public</jk> Person(String name, <jk>int</jk> age) {
+	 *				<jk>this</jk>.<jf>name</jf> = name;
+	 *				<jk>this</jk>.<jf>age</jf> = age;
+	 *			}
+	 *
+	 *			<jc>// Read only properties.</jc>
+	 *			<jc>// Getters, but no setters.</jc>
+	 *
+	 *			<jk>public</jk> String getName() {
+	 *				<jk>return</jk> <jf>name</jf>;
+	 *			}
+	 *
+	 *			<jk>public int</jk> getAge() {
+	 *				<jk>return</jk> <jf>age</jf>;
+	 *			}
+	 *		}			
+	 *	</p>
+	 *	<p class='bpcode w800'>
+	 *		<jc>// Parsing into a read-only bean.</jc>
+	 *		String json = <js>"{name:'John Smith',age:45}"</js>;
+	 *		Person p = JsonParser.<jsf>DEFAULT</jsf>.parse(json);
+	 *		String name = p.getName();  <jc>// "John Smith"</jc>
+	 *		<jk>int</jk> age = p.getAge();   <jc>// 45</jc>
+	 *	</p>
+	*/
+	
 	String properties() default "";
 }
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index a85e616fe..5ac5d7975 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -2726,7 +2726,7 @@ <h4 class='topic ' onclick='toggle(this)'><a href='#juneau-marshall.Transforms.B
 		<jk>private final</jk> String <jf>name</jf>;
 		<jk>private final int</jk> <jf>age</jf>;
 
-		<ja>@BeanConstructor</ja>(properties=<js>"name,age"</js>})
+		<ja>@BeanConstructor</ja>(properties=<js>"name,age"</js>)
 		<jk>public</jk> Person(String name, <jk>int</jk> age) {
 			<jk>this</jk>.<jf>name</jf> = name;
 			<jk>this</jk>.<jf>age</jf> = age;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message