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 280b0f4 Remove deprecated code.
280b0f4 is described below
commit 280b0f42524b503d7d19b7fdc1ac22e27c44de1a
Author: JamesBognar <[email protected]>
AuthorDate: Tue Oct 13 12:42:39 2020 -0400
Remove deprecated code.
---
.../main/java/org/apache/juneau/BeanContext.java | 32 +-
.../src/main/java/org/apache/juneau/BeanMeta.java | 49 +--
.../java/org/apache/juneau/BeanPropertyMeta.java | 36 +--
.../apache/juneau/annotation/BeanConstructor.java | 109 -------
.../org/apache/juneau/annotation/BeanProperty.java | 338 ---------------------
5 files changed, 12 insertions(+), 552 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index 49ad117..d1a9488 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -2991,7 +2991,6 @@ public class BeanContext extends Context implements
MetaProvider {
* Used for determining the class type on a method or field where a
{@code @Beanp} annotation may be present.
*
* @param <T> The class type we're wrapping.
- * @param px The property annotation on the type if there is one.
* @param p The property annotation on the type if there is one.
* @param t The type.
* @param typeVarImpls
@@ -3000,38 +2999,9 @@ public class BeanContext extends Context implements
MetaProvider {
* Can be <jk>null</jk> if the information is not known.
* @return The new {@code ClassMeta} object wrapped around the {@code
Type} object.
*/
- @SuppressWarnings("deprecation")
- protected final <T> ClassMeta<T> resolveClassMeta(BeanProperty px,
Beanp p, Type t, Map<Class<?>,Class<?>[]> typeVarImpls) {
+ protected final <T> ClassMeta<T> resolveClassMeta(Beanp p, Type t,
Map<Class<?>,Class<?>[]> typeVarImpls) {
ClassMeta<T> cm = resolveClassMeta(t, typeVarImpls);
ClassMeta<T> cm2 = cm;
- if (px != null) {
-
- if (px.type() != Object.class)
- cm2 = resolveClassMeta(px.type(), typeVarImpls);
-
- if (cm2.isMap()) {
- Class<?>[] pParams = (px.params().length == 0 ?
new Class[]{Object.class, Object.class} : px.params());
- if (pParams.length != 2)
- throw new
BasicRuntimeException("Invalid number of parameters specified for Map (must be
2): {0}", pParams.length);
- ClassMeta<?> keyType = resolveType(pParams[0],
cm2.getKeyType(), cm.getKeyType());
- ClassMeta<?> valueType =
resolveType(pParams[1], cm2.getValueType(), cm.getValueType());
- if (keyType.isObject() && valueType.isObject())
- return cm2;
- return new ClassMeta<>(cm2, keyType, valueType,
null);
- }
-
- if (cm2.isCollection() || cm2.isOptional()) {
- Class<?>[] pParams = (px.params().length == 0 ?
new Class[]{Object.class} : px.params());
- if (pParams.length != 1)
- throw new
BasicRuntimeException("Invalid number of parameters specified for
"+(cm2.isCollection() ? "Collection" : cm2.isOptional() ? "Optional" :
"Array")+" (must be 1): {0}", pParams.length);
- ClassMeta<?> elementType =
resolveType(pParams[0], cm2.getElementType(), cm.getElementType());
- if (elementType.isObject())
- return cm2;
- return new ClassMeta<>(cm2, null, null,
elementType);
- }
-
- return cm2;
- }
if (p != null) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
index 350978c..2e4d9a1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanMeta.java
@@ -164,7 +164,6 @@ public class BeanMeta<T> {
this.pNames = pNames;
}
- @SuppressWarnings("deprecation")
String init(BeanMeta<T> beanMeta) {
Class<?> c = classMeta.getInnerClass();
ClassInfo ci = classMeta.getInfo();
@@ -226,25 +225,6 @@ public class BeanMeta<T> {
// Look for @Beanc constructor on public
constructors.
for (ConstructorInfo x :
ci.getPublicConstructors()) {
- if
(x.hasAnnotation(BeanConstructor.class)) {
- if (constructor != null)
- throw new
BeanRuntimeException(c, "Multiple instances of '@BeanConstructor' found.");
- constructor = x;
- constructorArgs =
split(x.getAnnotation(BeanConstructor.class).properties());
- if (constructorArgs.length !=
x.getParamCount()) {
- if
(constructorArgs.length != 0)
- throw new
BeanRuntimeException(c, "Number of properties defined in '@BeanConstructor'
annotation does not match number of parameters in constructor.");
- constructorArgs = new
String[x.getParamCount()];
- int i = 0;
- for (ParamInfo pi :
x.getParams()) {
- String pn =
pi.getName();
- if (pn == null)
- throw
new BeanRuntimeException(c, "Could not find name for parameter #{0} of
constructor ''{1}''", i, x.getFullName());
-
constructorArgs[i++] = pn;
- }
- }
- constructor.setAccessible();
- }
if (ctx.hasAnnotation(Beanc.class, x)) {
if (constructor != null)
throw new
BeanRuntimeException(c, "Multiple instances of '@Beanc' found.");
@@ -386,10 +366,7 @@ public class BeanMeta<T> {
// Two getters. Pick
the best.
if (bpm.getter != null)
{
- if
(m.getAnnotation(BeanProperty.class) == null &&
bpm.getter.getAnnotation(BeanProperty.class) != null)
- m =
bpm.getter; // @BeanProperty annotated method takes precedence.
-
- else if (!
ctx.hasAnnotation(Beanp.class, m) && ctx.hasAnnotation(Beanp.class, bpm.getter))
+ if (!
ctx.hasAnnotation(Beanp.class, m) && ctx.hasAnnotation(Beanp.class, bpm.getter))
m =
bpm.getter; // @Beanp annotated method takes precedence.
else if
(m.getName().startsWith("is") && bpm.getter.getName().startsWith("get"))
@@ -565,11 +542,9 @@ public class BeanMeta<T> {
* Returns null if the field isn't a valid property.
*/
private String findPropertyName(Field f) {
- @SuppressWarnings("deprecation")
- BeanProperty px = f.getAnnotation(BeanProperty.class);
List<Beanp> lp = ctx.getAnnotations(Beanp.class, f);
List<Name> ln = ctx.getAnnotations(Name.class, f);
- String name = bpName(px, lp, ln);
+ String name = bpName(lp, ln);
if (isNotEmpty(name))
return name;
return propertyNamer.getPropertyName(f.getName());
@@ -703,11 +678,9 @@ public class BeanMeta<T> {
if (t != null && t.value())
continue;
- @SuppressWarnings("deprecation")
- BeanProperty px =
m.getLastAnnotation(BeanProperty.class);
List<Beanp> lp =
ctx.getAnnotations(Beanp.class, m);
List<Name> ln = ctx.getAnnotations(Name.class,
m);
- if (! (m.isVisible(v) || px != null ||
lp.size() > 0 || ln.size() > 0))
+ if (! (m.isVisible(v) || lp.size() > 0 ||
ln.size() > 0))
continue;
String n = m.getSimpleName();
@@ -715,7 +688,7 @@ public class BeanMeta<T> {
List<ClassInfo> pt = m.getParamTypes();
ClassInfo rt = m.getReturnType();
MethodType methodType = UNKNOWN;
- String bpName = bpName(px, lp, ln);
+ String bpName = bpName(lp, ln);
if (pt.size() == 0) {
if ("*".equals(bpName)) {
@@ -807,11 +780,9 @@ public class BeanMeta<T> {
if (ctx.hasAnnotation(BeanIgnore.class, f))
continue;
- @SuppressWarnings("deprecation")
- BeanProperty px =
f.getAnnotation(BeanProperty.class);
List<Beanp> lp =
ctx.getAnnotations(Beanp.class, f);
- if (! (v.isVisible(f.inner()) || px != null ||
lp.size() > 0))
+ if (! (v.isVisible(f.inner()) || lp.size() > 0))
continue;
l.add(f.inner());
@@ -1006,9 +977,8 @@ public class BeanMeta<T> {
return beanFilter == null ? value :
beanFilter.writeProperty(bean, name, value);
}
- @SuppressWarnings("deprecation")
- static final String bpName(BeanProperty px, List<Beanp> p, List<Name>
n) {
- if (px == null && p.isEmpty() && n.isEmpty())
+ static final String bpName(List<Beanp> p, List<Name> n) {
+ if (p.isEmpty() && n.isEmpty())
return null;
if (! n.isEmpty())
return last(n).value();
@@ -1023,11 +993,6 @@ public class BeanMeta<T> {
if (name != null)
return name;
- if (px != null) {
- if (! px.name().isEmpty())
- return px.name();
- return px.value();
- }
return null;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
index 8c9dea1..338d3ac 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java
@@ -161,7 +161,6 @@ public final class BeanPropertyMeta {
return this;
}
- @SuppressWarnings("deprecation")
boolean validate(BeanContext bc, BeanRegistry
parentBeanRegistry, Map<Class<?>,Class<?>[]> typeVarImpls, Set<String> bpro,
Set<String> bpwo) throws Exception {
AList<Class<?>> bdClasses = AList.of();
@@ -176,19 +175,13 @@ public final class BeanPropertyMeta {
canWrite |= (field != null || setter != null);
if (innerField != null) {
- BeanProperty px =
innerField.getAnnotation(BeanProperty.class);
List<Beanp> lp = bc.getAnnotations(Beanp.class,
innerField);
- if (field != null || px != null || lp.size() >
0) {
+ if (field != null || lp.size() > 0) {
// Only use field type if it's a bean
property or has @Beanp annotation.
// Otherwise, we want to infer the type
from the getter or setter.
- rawTypeMeta = bc.resolveClassMeta(px,
last(lp), innerField.getGenericType(), typeVarImpls);
+ rawTypeMeta =
bc.resolveClassMeta(last(lp), innerField.getGenericType(), typeVarImpls);
isUri |= (rawTypeMeta.isUri());
}
- if (px != null) {
- if (! px.properties().isEmpty())
- properties =
split(px.properties());
- bdClasses.a(px.beanDictionary());
- }
for (Beanp p : lp) {
if (! p.properties().isEmpty())
properties =
split(p.properties());
@@ -204,16 +197,10 @@ public final class BeanPropertyMeta {
}
if (getter != null) {
- BeanProperty px =
MethodInfo.of(getter).getLastAnnotation(BeanProperty.class);
List<Beanp> lp = bc.getAnnotations(Beanp.class,
getter);
if (rawTypeMeta == null)
- rawTypeMeta = bc.resolveClassMeta(px,
last(lp), getter.getGenericReturnType(), typeVarImpls);
+ rawTypeMeta =
bc.resolveClassMeta(last(lp), getter.getGenericReturnType(), typeVarImpls);
isUri |= (rawTypeMeta.isUri() ||
bc.hasAnnotation(org.apache.juneau.annotation.URI.class, getter));
- if (px != null) {
- if (properties != null && !
px.properties().isEmpty())
- properties =
split(px.properties());
- bdClasses.a(px.beanDictionary());
- }
for (Beanp p : lp) {
if (properties != null && !
p.properties().isEmpty())
properties =
split(p.properties());
@@ -228,18 +215,10 @@ public final class BeanPropertyMeta {
}
if (setter != null) {
- BeanProperty px =
MethodInfo.of(setter).getLastAnnotation(BeanProperty.class);
List<Beanp> lp = bc.getAnnotations(Beanp.class,
setter);
if (rawTypeMeta == null)
- rawTypeMeta = bc.resolveClassMeta(px,
last(lp), setter.getGenericParameterTypes()[0], typeVarImpls);
+ rawTypeMeta =
bc.resolveClassMeta(last(lp), setter.getGenericParameterTypes()[0],
typeVarImpls);
isUri |= (rawTypeMeta.isUri() ||
bc.hasAnnotation(org.apache.juneau.annotation.URI.class, setter));
- if (px != null) {
- if (swap == null)
- swap = getPropertyPojoSwap(px);
- if (properties != null && !
px.properties().isEmpty())
- properties =
split(px.properties());
- bdClasses.a(px.beanDictionary());
- }
for (Beanp p : lp) {
if (swap == null)
swap = getPropertyPojoSwap(p);
@@ -332,13 +311,6 @@ public final class BeanPropertyMeta {
return new BeanPropertyMeta(this);
}
- @SuppressWarnings("deprecation")
- private PojoSwap getPropertyPojoSwap(BeanProperty p) throws
Exception {
- if (! p.format().isEmpty())
- return castOrCreate(PojoSwap.class,
StringFormatSwap.class, false, p.format());
- return null;
- }
-
private PojoSwap getPropertyPojoSwap(Beanp p) throws Exception {
if (! p.format().isEmpty())
return castOrCreate(PojoSwap.class,
StringFormatSwap.class, false, p.format());
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
deleted file mode 100644
index 85c5269..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConstructor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-import org.apache.juneau.*;
-
-/**
- * Maps constructor arguments to property names on beans with read-only
properties.
- *
- * <p>
- * This annotation can be used in the case of beans with properties whose
values can only be set by passing them in
- * through a constructor on the class.
- * <br>Since method parameter names are lost during compilation, this
annotation essentially redefines them so that they
- * are available at runtime.
- *
- * <p>
- * This annotation can only be applied to constructors and can only be applied
to one constructor per class.
- *
- * <p>
- * When present, bean instantiation is delayed until the call to {@link
BeanMap#getBean()}.
- * Until then, bean property values are stored in a local cache until
<c>getBean()</c> is called.
- * Because of this additional caching step, parsing into read-only beans tends
to be slower and use more memory than
- * parsing into beans with writable properties.
- *
- * <p>
- * Attempting to call {@link BeanMap#put(String,Object)} on a read-only
property after calling {@link BeanMap#getBean()}
- * will result in a {@link BeanRuntimeException} being thrown.
- * Multiple calls to {@link BeanMap#getBean()} will return the same bean
instance.
- *
- * <ul class='seealso'>
- * <li class='link'>{@doc BeancAnnotation}
- * </ul>
- *
- * <div class='warn'>
- * <b>Deprecated</b> - {@link Beanc}.
- * </div>
- */
-@Documented
-@Target(CONSTRUCTOR)
-@Retention(RUNTIME)
-@Inherited
-@Deprecated
-public @interface BeanConstructor {
-
- /**
- * The names of the properties of the constructor arguments.
- * <p>
- * 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>
- * <p>
- * Note that the {@link Name @Name} annotation can also be used to
identify bean property names on constructor
- * arguments. If neither this annotation or {@link Name @Name} is
used, then we try to get the property names
- * from the parameter names if they are available in the bytecode.
- * </p>
- */
- String properties() default "";
-}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanProperty.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanProperty.java
deleted file mode 100644
index e29de36..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanProperty.java
+++ /dev/null
@@ -1,338 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-import org.apache.juneau.*;
-
-/**
- * Used tailor how bean properties get interpreted by the framework.
- *
- * <p>
- * This annotation is applied to public fields and public getter/setter
methods of beans.
- *
- * <ul class='seealso'>
- * <li class='link'>{@doc BeanpAnnotation}
- * </ul>
- *
- * <div class='warn'>
- * <b>Deprecated</b> - {@link Beanp}.
- * </div>
- */
-@Documented
-@Target({FIELD,METHOD,PARAMETER})
-@Retention(RUNTIME)
-@Inherited
-@Deprecated
-public @interface BeanProperty {
-
- /**
- * Identifies the name of the property.
- *
- * <p>
- * Normally, this is automatically inferred from the field name or
getter method name of the property.
- * However, this property can be used to assign a different property
name from the automatically inferred value.
- *
- * <p>
- * If the {@link BeanContext#BEAN_beanFieldVisibility} setting on the
bean context excludes this field (e.g. the
- * visibility is set to PUBLIC, but the field is PROTECTED), this
annotation can be used to force the field to be
- * identified as a property.
- *
- * <h5 class='topic'>Dynamic beans</h5>
- * <p>
- * The bean property named <js>"*"</js> is the designated "dynamic
property" which allows for "extra" bean
- * properties not otherwise defined.
- * This is similar in concept to the Jackson <ja>@JsonGetterAll</ja>
and <ja>@JsonSetterAll</ja> annotations.
- * The primary purpose is for backwards compatibility in parsing newer
streams with addition information into older
- * beans.
- *
- * <p>
- * The following examples show how to define dynamic bean properties.
- * <p class='bcode w800'>
- * <jc>// Option #1 - A simple public Map field.
- * // The field name can be anything.</jc>
- * <jk>public class</jk> BeanWithDynaField {
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public</jk> Map<String,Object> extraStuff =
<jk>new</jk> LinkedHashMap<String,Object>();
- * }
- *
- * <jc>// Option #2 - Getters and setters.
- * // Method names can be anything.
- * // Getter must return a Map with String keys.
- * // Setter must take in two arguments.</jc>
- * <jk>public class</jk> BeanWithDynaMethods {
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public</jk> Map<String,Object>
getMyExtraStuff() {
- * ...
- * }
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public void</jk> setAnExtraField(String name,
Object value) {
- * ...
- * }
- * }
- *
- * <jc>// Option #3 - Getter only.
- * // Properties will be added through the getter.</jc>
- * <jk>public class</jk> BeanWithDynaGetterOnly {
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public</jk> Map<String,Object>
getMyExtraStuff() {
- * ...
- * }
- * }
- *
- * <jc>// Option #4 - Getter, setter, and extra-keys method .
- * // Define a method that returns a Collection<String> with
currently-set property names.</jc>
- * <jk>public class</jk> BeanWithDynaExtraKeys {
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public</jk> Object get(String name) {
- * ...
- * }
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public void</jk> set(String name, Object value) {
- * ...
- * }
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public</jk> Collection<String> extraKeys() {
- * ...
- * }
- * }
- * </p>
- *
- *<p>
- * Similar rules apply for value types and swaps.
- * The property values optionally can be any serializable type or use
swaps.
- * <p class='bcode w800'>
- * <jc>// A serializable type other than Object.</jc>
- * <jk>public class</jk> BeanWithDynaFieldWithListValues {
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>)
- * <jk>public</jk> Map<String,List<String>>
getMyExtraStuff() {
- * ...
- * }
- * }
- *
- * <jc>// A swapped value.</jc>
- * <jk>public class</jk> BeanWithDynaFieldWithSwappedValues {
- *
- * <ja>@BeanProperty</ja>(name=<js>"*"</js>,
swap=TemporalCalendarSwap.IsoLocalDateTime.<jk>class</jk>)
- * <jk>public</jk> Map<String,Calendar>
getMyExtraStuff() {
- * ...
- * }
- * }
- * </p>
- *
- * <div class='info'>
- * Note that if you're not interested in these additional
properties, you can also use the
- * {@link BeanContext#BEAN_ignoreUnknownBeanProperties} setting to
ignore values that don't fit into existing
- * properties.
- * </div>
- * <div class='info'>
- * Note that the {@link Name @Name} annotation can also be
used for identifying a property name.
- * </div>
- */
- String name() default "";
-
- /**
- * A synonym for {@link #name()}.
- *
- * <p>
- * The following annotations are equivalent:
- *
- * <p class='bcode w800'>
- * <ja>@BeanProperty</ja>(name=<js>"foo"</js>)
- *
- * <ja>@BeanProperty</ja>(<js>"foo"</js>)
- * </p>
- */
- String value() default "";
-
- /**
- * Identifies a specialized class type for the property.
- *
- * <p>
- * Normally this can be inferred through reflection of the field type
or getter return type.
- * However, you'll want to specify this value if you're parsing beans
where the bean property class is an interface
- * or abstract class to identify the bean type to instantiate.
- * Otherwise, you may cause an {@link InstantiationException} when
trying to set these fields.
- *
- * <p>
- * This property must denote a concrete bean class with a no-arg
constructor.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jk>public class</jk> MyBean {
- *
- * <jc>// Identify concrete map type.</jc>
- * <ja>@BeanProperty</ja>(type=HashMap.<jk>class</jk>)
- * <jk>public</jk> Map <jf>p1</jf>;
- * }
- * </p>
- *
- * <p>
- * This annotation can also be used on private fields of a property
like so:
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jk>public class</jk> MyBean {
- *
- * <ja>@BeanProperty</ja>(type=HashMap.<jk>class</jk>)
- * <jk>private</jk> Map <jf>p1</jf>;
- *
- * <jk>public</jk> Map getP1() {
- * <jk>return</jk> <jf>p1</jf>;
- * }
- * }
- * </p>
- */
- Class<?> type() default Object.class;
-
- /**
- * For bean properties of maps and collections, this annotation can be
used to identify the class types of the
- * contents of the bean property object when the generic parameter
types are interfaces or abstract classes.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jk>public class</jk> MyBean {
- *
- * <jc>// Identify concrete map type with String keys and
Integer values.</jc>
- * <ja>@BeanProperty</ja>(type=HashMap.<jk>class</jk>,
params={String.<jk>class</jk>,Integer.<jk>class</jk>})
- * <jk>public</jk> Map <jf>p1</jf>;
- * }
- * </p>
- *
- * <p>
- * This annotation can also be used on private fields of a property
like so:
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jk>public class</jk> MyBean {
- *
- * <ja>@BeanProperty</ja>(type=HashMap.<jk>class</jk>,
params={String.<jk>class</jk>,Integer.<jk>class</jk>})
- * <jk>private</jk> Map <jf>p1</jf>;
- *
- * <jk>public</jk> Map getP1() {
- * <jk>return</jk> <jf>p1</jf>;
- * }
- * }
- * </p>
- */
- Class<?>[] params() default {};
-
- /**
- * Used to limit which child properties are rendered by the serializers.
- *
- * <p>
- * Can be used on any of the following bean property types:
- * <ul class='spaced-list'>
- * <li>Beans - Only render the specified properties of the bean.
- * <li>Maps - Only render the specified entries in the map.
- * <li>Bean/Map arrays - Same, but applied to each element in the
array.
- * <li>Bean/Map collections - Same, but applied to each element in
the collection.
- * </ul>
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jk>public class</jk> MyClass {
- *
- * <jc>// Only render 'f1' when serializing this bean
property.</jc>
- * <ja>@BeanProperty</ja>(bpi=<js>"f1"</js>)
- * <jk>public</jk> MyChildClass x1 = <jk>new</jk>
MyChildClass();
- * }
- *
- * <jk>public class</jk> MyChildClass {
- * <jk>public int</jk> f1 = 1;
- * <jk>public int</jk> f2 = 2;
- * }
- *
- * <jc>// Renders "{x1:{f1:1}}"</jc>
- * String json =
JsonSerializer.<jsf>DEFAULT</jsf>.serialize(<jk>new</jk> MyClass());
- * </p>
- *
- * <p>
- * This annotation can also be used on private fields of a property
like so:
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jk>public class</jk> MyBean {
- *
- * <ja>@BeanProperty</ja>(properties=<js>"f1"</js>)
- * <jk>private</jk> MyChildClass <jf>x1</jf>;
- *
- * <jk>public</jk> MyChildClass getX1() {
- * <jk>return</jk> <jf>x1</jf>;
- * }
- * }
- * </p>
- */
- String properties() default "";
-
- /**
- * Bean dictionary.
- *
- * <p>
- * The list of classes that make up the bean dictionary this bean
property.
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link BeanContext#BEAN_beanDictionary}
- * </ul>
- *
- * <p>
- * This annotation can also be used on private fields of a property.
- */
- Class<?>[] beanDictionary() default {};
-
- /**
- * Specifies a String format for converting the bean property value to
a formatted string.
- *
- * <p>
- * Note that this is usually a one-way conversion during serialization.
- *
- * <p>
- * During parsing, we will attempt to convert the value to the original
form by using the
- * {@link BeanSession#convertToType(Object, Class)} but there is no
guarantee that this will succeed.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <ja>@BeanProperty</ja>(format=<js>"$%.2f"</js>)
- * <jk>public float</jk> <jf>price</jf>;
- * </p>
- *
- * <p>
- * This annotation can also be used on private fields of a property
like so:
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jk>public class</jk> MyBean {
- *
- * <ja>@BeanProperty</ja>(format=<js>"$%.2f"</js>)
- * <jk>private float</jk> <jf>price</jf>;
- *
- * <jk>public float</jk> gePrice() {
- * <jk>return</jk> <jf>price</jf>;
- * }
- * }
- * </p>
- */
- String format() default "";
-}