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 988c777 Add @X(onClass) annotations. 988c777 is described below commit 988c7776e8519e2fa82b2ef181997a04d7d6ee2f Author: JamesBognar <james.bog...@salesforce.com> AuthorDate: Fri Oct 16 10:03:03 2020 -0400 Add @X(onClass) annotations. --- .../org/apache/juneau/jena/annotation/Rdf.java | 14 +- .../juneau/jena/annotation/RdfAnnotation.java | 106 +++-------- .../main/java/org/apache/juneau/BeanContext.java | 24 ++- .../java/org/apache/juneau/annotation/Bean.java | 14 +- .../apache/juneau/annotation/BeanAnnotation.java | 62 +++---- .../org/apache/juneau/annotation/BeanIgnore.java | 14 +- .../juneau/annotation/BeanIgnoreAnnotation.java | 116 +++--------- .../java/org/apache/juneau/annotation/Beanc.java | 2 +- .../apache/juneau/annotation/BeancAnnotation.java | 64 ++----- .../java/org/apache/juneau/annotation/Beanp.java | 2 +- .../apache/juneau/annotation/BeanpAnnotation.java | 91 +++------ .../java/org/apache/juneau/annotation/Example.java | 14 +- .../juneau/annotation/ExampleAnnotation.java | 107 +++-------- .../org/apache/juneau/annotation/NameProperty.java | 2 +- .../juneau/annotation/NamePropertyAnnotation.java | 73 ++------ .../apache/juneau/annotation/ParentProperty.java | 2 +- .../annotation/ParentPropertyAnnotation.java | 72 ++------ .../java/org/apache/juneau/annotation/Swap.java | 14 +- .../apache/juneau/annotation/SwapAnnotation.java | 120 ++++-------- .../juneau/annotation/TargetedAnnotation.java | 205 +++++++++++++++++++++ .../java/org/apache/juneau/annotation/URI.java | 14 +- .../apache/juneau/annotation/UriAnnotation.java | 93 +--------- .../java/org/apache/juneau/csv/annotation/Csv.java | 14 +- .../juneau/csv/annotation/CsvAnnotation.java | 96 +++------- .../org/apache/juneau/html/annotation/Html.java | 14 +- .../juneau/html/annotation/HtmlAnnotation.java | 107 +++-------- .../apache/juneau/html/annotation/HtmlLink.java | 14 +- .../juneau/html/annotation/HtmlLinkAnnotation.java | 70 +++---- .../juneau/http/annotation/AnnotationUtils.java | 4 +- .../java/org/apache/juneau/jso/annotation/Jso.java | 14 +- .../juneau/jso/annotation/JsoAnnotation.java | 96 +++------- .../org/apache/juneau/json/annotation/Json.java | 14 +- .../juneau/json/annotation/JsonAnnotation.java | 106 +++-------- .../juneau/jsonschema/annotation/Schema.java | 14 +- .../jsonschema/annotation/SchemaAnnotation.java | 70 +++---- .../apache/juneau/msgpack/annotation/MsgPack.java | 14 +- .../msgpack/annotation/MsgPackAnnotation.java | 96 +++------- .../org/apache/juneau/oapi/annotation/OpenApi.java | 14 +- .../juneau/oapi/annotation/OpenApiAnnotation.java | 96 +++------- .../juneau/plaintext/annotation/PlainText.java | 14 +- .../plaintext/annotation/PlainTextAnnotation.java | 96 +++------- .../org/apache/juneau/soap/annotation/SoapXml.java | 14 +- .../juneau/soap/annotation/SoapXmlAnnotation.java | 96 +++------- .../java/org/apache/juneau/uon/annotation/Uon.java | 14 +- .../juneau/uon/annotation/UonAnnotation.java | 96 +++------- .../juneau/urlencoding/annotation/UrlEncoding.java | 14 +- .../annotation/UrlEncodingAnnotation.java | 98 +++------- .../java/org/apache/juneau/xml/annotation/Xml.java | 14 +- .../juneau/xml/annotation/XmlAnnotation.java | 106 +++-------- .../main/ConfigurablePropertyCodeGenerator.java | 51 ++++- 50 files changed, 1061 insertions(+), 1630 deletions(-) diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/Rdf.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/Rdf.java index ca7854a..1ed4d1a 100644 --- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/Rdf.java +++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/Rdf.java @@ -149,7 +149,19 @@ public @interface Rdf { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * Sets the XML prefix of this property or class. diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java index 39dae75..4563811 100644 --- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java +++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java @@ -16,8 +16,8 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; +import org.apache.juneau.annotation.*; import org.apache.juneau.jena.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link Rdf} annotation. @@ -26,10 +26,9 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class RdfAnnotation implements Rdf { +public class RdfAnnotation extends TargetedAnnotation.OnClassMethodField implements Rdf { private String - on = "", namespace = "", prefix = ""; private boolean @@ -43,45 +42,10 @@ public class RdfAnnotation implements Rdf { * @param on The initial value for the <c>on</c> property. * <br>See {@link Rdf#on()} */ - public RdfAnnotation(String on) { + public RdfAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Rdf#on()} - */ - public RdfAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Rdf#on()} - */ - public RdfAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Rdf#on()} - */ - public RdfAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Rdf.class; - } - @Override public boolean beanUri() { return beanUri; @@ -131,68 +95,52 @@ public class RdfAnnotation implements Rdf { } @Override - public String on() { - return on; + public String prefix() { + return prefix; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>prefix</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public RdfAnnotation on(String value) { - this.on = value; + public RdfAnnotation prefix(String value) { + this.prefix = value; return this; } + // <FluentSetters> - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public RdfAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - TargetedAnnotation */ + public RdfAnnotation on(String...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public RdfAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClass */ + public RdfAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public RdfAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public RdfAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - @Override - public String prefix() { - return prefix; + @Override /* GENERATED - OnClassMethodField */ + public RdfAnnotation on(Field...value) { + super.on(value); + return this; } - /** - * Sets the <c>prefix</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public RdfAnnotation prefix(String value) { - this.prefix = value; + @Override /* GENERATED - OnClassMethodField */ + public RdfAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } 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 241af65..67ecd61 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 @@ -2316,12 +2316,24 @@ public class BeanContext extends Context implements MetaProvider { ReflectionMap.Builder<Annotation> rmb = ReflectionMap.create(Annotation.class); for (Annotation a : ps.getListProperty(BEAN_annotations, Annotation.class)) { try { - Method m = a.getClass().getMethod("on"); - m.setAccessible(true); - String on = (String)m.invoke(a); - rmb.append(on, a); - } catch (NoSuchMethodException e) { - throw new ConfigException("Invalid annotation @{0} used in BEAN_annotations property. Annotation must define an on() method.", a.getClass().getSimpleName()); + ClassInfo ci = ClassInfo.of(a.getClass()); + + MethodInfo mi = ci.getMethod("onClass"); + if (mi != null) { + if (! mi.getReturnType().is(Class[].class)) + throw new ConfigException("Invalid annotation @{0} used in BEAN_annotations property. Annotation must define an onClass() method that returns a Class array.", a.getClass().getSimpleName()); + for (Class<?> c : (Class<?>[])mi.accessible().invoke(a)) + rmb.append(c.getName(), a); + } + + mi = ci.getMethod("on"); + if (mi != null) { + if (! mi.getReturnType().is(String[].class)) + throw new ConfigException("Invalid annotation @{0} used in BEAN_annotations property. Annotation must define an on() method that returns a String array.", a.getClass().getSimpleName()); + for (String s : (String[])mi.accessible().invoke(a)) + rmb.append(s, a); + } + } catch (Exception e) { throw new ConfigException(e, "Invalid annotation @{0} used in BEAN_annotations property.", a.getClass().getName()); } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java index 9c1450f..a3e3e37 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Bean.java @@ -279,7 +279,19 @@ public @interface Bean { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * Associates a {@link PropertyNamer} with this bean to tailor the names of the bean properties. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java index 31d19fe..7216191 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java @@ -24,9 +24,7 @@ import org.apache.juneau.transform.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class BeanAnnotation implements Bean { - - private String on = ""; +public class BeanAnnotation extends TargetedAnnotation.OnClass implements Bean { private Class<?>[] dictionary = new Class[0]; @@ -53,7 +51,7 @@ public class BeanAnnotation implements Bean { * * @param on The initial value for the <c>on</c> property. */ - public BeanAnnotation(String on) { + public BeanAnnotation(String...on) { on(on); } @@ -62,16 +60,11 @@ public class BeanAnnotation implements Bean { * * @param on The initial value for the <c>on</c> property. */ - public BeanAnnotation(Class<?> on) { + public BeanAnnotation(Class<?>...on) { on(on); } @Override - public Class<? extends Annotation> annotationType() { - return Bean.class; - } - - @Override public String bpi() { return bpi; } @@ -184,33 +177,6 @@ public class BeanAnnotation implements Bean { } @Override - public String on() { - return on; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanAnnotation on(String value) { - this.on = value; - return this; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanAnnotation on(Class<?> value) { - this.on = value.getName(); - return this; - } - - @Override public Class<? extends BeanInterceptor<?>> interceptor() { return interceptor; } @@ -305,4 +271,26 @@ public class BeanAnnotation implements Bean { this.typePropertyName = value; return this; } + + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public BeanAnnotation on(String...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnClass */ + public BeanAnnotation on(java.lang.Class<?>...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnClass */ + public BeanAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); + return this; + } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnore.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnore.java index 6ca9845..966079a 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnore.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnore.java @@ -144,6 +144,18 @@ public @interface BeanIgnore { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java index 90b4ac8..2454d6a 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java @@ -16,7 +16,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link BeanIgnore} annotation. @@ -25,29 +24,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class BeanIgnoreAnnotation implements BeanIgnore { - - private String on = ""; - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link BeanIgnore#on()} - */ - public BeanIgnoreAnnotation(String on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link BeanIgnore#on()} - */ - public BeanIgnoreAnnotation(Class<?> on) { - on(on); - } +public class BeanIgnoreAnnotation extends TargetedAnnotation.OnClassMethodFieldConstructor implements BeanIgnore { /** * Constructor. @@ -55,92 +32,47 @@ public class BeanIgnoreAnnotation implements BeanIgnore { * @param on The initial value for the <c>on</c> property. * <br>See {@link BeanIgnore#on()} */ - public BeanIgnoreAnnotation(Method on) { + public BeanIgnoreAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link BeanIgnore#on()} - */ - public BeanIgnoreAnnotation(Field on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link BeanIgnore#on()} - */ - public BeanIgnoreAnnotation(Constructor<?> on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return BeanIgnore.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public BeanIgnoreAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanIgnoreAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public BeanIgnoreAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanIgnoreAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public BeanIgnoreAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanIgnoreAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public BeanIgnoreAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanIgnoreAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public BeanIgnoreAnnotation on(Method...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanIgnoreAnnotation on(Constructor<?> value) { - this.on = ConstructorInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodFieldConstructor */ + public BeanIgnoreAnnotation on(java.lang.reflect.Constructor<?>...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanc.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanc.java index 194e874..34ab54e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanc.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanc.java @@ -125,7 +125,7 @@ public @interface Beanc { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; /** * The names of the properties of the constructor arguments. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java index 90384c5..470024a 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java @@ -13,10 +13,8 @@ package org.apache.juneau.annotation; import java.lang.annotation.*; -import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link Beanc} annotation. @@ -25,9 +23,9 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class BeancAnnotation implements Beanc { +public class BeancAnnotation extends TargetedAnnotation.OnConstructor implements Beanc { - private String on="", properties=""; + private String properties=""; /** * Constructor. @@ -35,65 +33,39 @@ public class BeancAnnotation implements Beanc { * @param on The initial value for the <c>on</c> property. * <br>See {@link Beanc#on()} */ - public BeancAnnotation(String on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Beanc#on()} - */ - public BeancAnnotation(Constructor<?> on) { + public BeancAnnotation(String...on) { on(on); } @Override - public Class<? extends Annotation> annotationType() { - return Beanc.class; - } - - @Override - public String on() { - return on; + public String properties() { + return properties; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>properties</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public BeancAnnotation on(String value) { - this.on = value; + public BeancAnnotation properties(String value) { + this.properties = value; return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeancAnnotation on(Constructor<?> value) { - this.on = ConstructorInfo.of(value).getFullName(); - return this; - } + // <FluentSetters> - @Override - public String properties() { - return properties; + @Override /* GENERATED - TargetedAnnotation */ + public BeancAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>properties</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeancAnnotation properties(String value) { - this.properties = value; + @Override /* GENERATED - OnConstructor */ + public BeancAnnotation on(java.lang.reflect.Constructor<?>...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java index bdd404b..0aad82e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Beanp.java @@ -265,7 +265,7 @@ public @interface Beanp { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; /** * For bean properties of maps and collections, this annotation can be used to identify the class types of the diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java index 3c1c994..919af2d 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java @@ -16,7 +16,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link Beanp} annotation. @@ -25,10 +24,9 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class BeanpAnnotation implements Beanp { +public class BeanpAnnotation extends TargetedAnnotation.OnMethodField implements Beanp { private String - on = "", name = "", value = "", properties = "", @@ -47,35 +45,10 @@ public class BeanpAnnotation implements Beanp { * @param on The initial value for the <c>on</c> property. * <br>See {@link Beanp#on()} */ - public BeanpAnnotation(String on) { + public BeanpAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Beanp#on()} - */ - public BeanpAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Beanp#on()} - */ - public BeanpAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Beanp.class; - } - @Override public String name() { return name; @@ -125,44 +98,6 @@ public class BeanpAnnotation implements Beanp { } @Override - public String on() { - return on; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanpAnnotation on(String value) { - this.on = value; - return this; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanpAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); - return this; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public BeanpAnnotation on(Field value) { - this.on = value.getName(); - return this; - } - - @Override public Class<?>[] params() { return params; } @@ -257,4 +192,26 @@ public class BeanpAnnotation implements Beanp { this.wo = value; return this; } + + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public BeanpAnnotation on(String...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnMethodField */ + public BeanpAnnotation on(Field...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnMethodField */ + public BeanpAnnotation on(Method...value) { + super.on(value); + return this; + } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Example.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Example.java index d77f699..e3d1fb5 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Example.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Example.java @@ -144,7 +144,19 @@ public @interface Example { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * An example of a POJO class. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java index 207a2eb..65b48ef 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java @@ -16,7 +16,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link Example} annotation. @@ -25,9 +24,9 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class ExampleAnnotation implements Example { +public class ExampleAnnotation extends TargetedAnnotation.OnClassMethodField implements Example { - private String on = "", value = ""; + private String value = ""; /** * Constructor. @@ -35,107 +34,57 @@ public class ExampleAnnotation implements Example { * @param on The initial value for the <c>on</c> property. * <br>See {@link Example#on()} */ - public ExampleAnnotation(String on) { + public ExampleAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Example#on()} - */ - public ExampleAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Example#on()} - */ - public ExampleAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Example#on()} - */ - public ExampleAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Example.class; - } - @Override - public String on() { - return on; + public String value() { + return value; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>value</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public ExampleAnnotation on(String value) { - this.on = value; + public ExampleAnnotation value(String value) { + this.value = value; return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public ExampleAnnotation on(Field value) { - this.on = value.getName(); + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public ExampleAnnotation on(String...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public ExampleAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClass */ + public ExampleAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public ExampleAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public ExampleAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - @Override - public String value() { - return value; + @Override /* GENERATED - OnClassMethodField */ + public ExampleAnnotation on(Field...value) { + super.on(value); + return this; } - /** - * Sets the <c>value</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public ExampleAnnotation value(String value) { - this.value = value; + @Override /* GENERATED - OnClassMethodField */ + public ExampleAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NameProperty.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NameProperty.java index 14c6806..02fcb48 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NameProperty.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NameProperty.java @@ -96,5 +96,5 @@ public @interface NameProperty { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java index a7a1ae8..b862fce 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java @@ -16,7 +16,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link NameProperty} annotation. @@ -25,9 +24,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class NamePropertyAnnotation implements NameProperty { - - private String on = ""; +public class NamePropertyAnnotation extends TargetedAnnotation.OnMethodField implements NameProperty { /** * Constructor. @@ -35,69 +32,29 @@ public class NamePropertyAnnotation implements NameProperty { * @param on The initial value for the <c>on</c> property. * <br>See {@link NameProperty#on()} */ - public NamePropertyAnnotation(String on) { + public NamePropertyAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link NameProperty#on()} - */ - public NamePropertyAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link NameProperty#on()} - */ - public NamePropertyAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return NameProperty.class; - } - - @Override - public String on() { - return on; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public NamePropertyAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - TargetedAnnotation */ + public NamePropertyAnnotation on(String...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public NamePropertyAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + + @Override /* GENERATED - OnMethodField */ + public NamePropertyAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public NamePropertyAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnMethodField */ + public NamePropertyAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentProperty.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentProperty.java index e2dbed7..d84ae43 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentProperty.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentProperty.java @@ -99,5 +99,5 @@ public @interface ParentProperty { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java index ee45fe2..d1b37de 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java @@ -16,7 +16,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link ParentProperty} annotation. @@ -25,29 +24,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class ParentPropertyAnnotation implements ParentProperty { - - private String on = ""; - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link ParentProperty#on()} - */ - public ParentPropertyAnnotation(String on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link ParentProperty#on()} - */ - public ParentPropertyAnnotation(Method on) { - on(on); - } +public class ParentPropertyAnnotation extends TargetedAnnotation.OnMethodField implements ParentProperty { /** * Constructor. @@ -55,50 +32,29 @@ public class ParentPropertyAnnotation implements ParentProperty { * @param on The initial value for the <c>on</c> property. * <br>See {@link ParentProperty#on()} */ - public ParentPropertyAnnotation(Field on) { + public ParentPropertyAnnotation(String...on) { on(on); } - @Override - public Class<? extends Annotation> annotationType() { - return ParentProperty.class; - } - - @Override - public String on() { - return on; - } + // <FluentSetters> - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public ParentPropertyAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - TargetedAnnotation */ + public ParentPropertyAnnotation on(String...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public ParentPropertyAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnMethodField */ + public ParentPropertyAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public ParentPropertyAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnMethodField */ + public ParentPropertyAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Swap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Swap.java index 15d9183..8a6f256 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Swap.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Swap.java @@ -154,7 +154,19 @@ public @interface Swap { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * Identifies a template string along with this swap. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java index 55f8c73..b90dc5e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java @@ -16,7 +16,6 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link Swap} annotation. @@ -25,10 +24,9 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class SwapAnnotation implements Swap { +public class SwapAnnotation extends TargetedAnnotation.OnClassMethodField implements Swap { private String - on = "", template = ""; private Class<?> impl = Null.class, @@ -42,45 +40,10 @@ public class SwapAnnotation implements Swap { * @param on The initial value for the <c>on</c> property. * <br>See {@link Swap#on()} */ - public SwapAnnotation(String on) { + public SwapAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Swap#on()} - */ - public SwapAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Swap#on()} - */ - public SwapAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Swap#on()} - */ - public SwapAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Swap.class; - } - @Override public Class<?> impl() { return impl; @@ -114,83 +77,68 @@ public class SwapAnnotation implements Swap { } @Override - public String on() { - return on; + public String template() { + return template; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>template</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public SwapAnnotation on(String value) { - this.on = value; + public SwapAnnotation template(String value) { + this.template = value; return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SwapAnnotation on(Class<?> value) { - this.on = value.getName(); - return this; + @Override + public Class<?> value() { + return value; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>value</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public SwapAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + public SwapAnnotation value(Class<?> value) { + this.value = value; return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SwapAnnotation on(Field value) { - this.on = value.getName(); + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public SwapAnnotation on(String...value) { + super.on(value); return this; } - @Override - public String template() { - return template; + @Override /* GENERATED - OnClass */ + public SwapAnnotation on(java.lang.Class<?>...value) { + super.on(value); + return this; } - /** - * Sets the <c>template</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SwapAnnotation template(String value) { - this.template = value; + @Override /* GENERATED - OnClass */ + public SwapAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - @Override - public Class<?> value() { - return value; + @Override /* GENERATED - OnClassMethodField */ + public SwapAnnotation on(Field...value) { + super.on(value); + return this; } - /** - * Sets the <c>value</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SwapAnnotation value(Class<?> value) { - this.value = value; + @Override /* GENERATED - OnClassMethodField */ + public SwapAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/TargetedAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/TargetedAnnotation.java new file mode 100644 index 0000000..10af000 --- /dev/null +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/TargetedAnnotation.java @@ -0,0 +1,205 @@ +// *************************************************************************************************************************** +// * 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 java.lang.annotation.*; +import java.lang.reflect.*; + +import org.apache.juneau.internal.*; +import org.apache.juneau.reflect.*; + +/** + * An implementation of an annotation that has an <code>on</code> value targeting classes/methods/fields/constructors. + */ +public class TargetedAnnotation { + + private String[] on = new String[0]; + + /** + * The targets this annotation applies to. + * + * @return The targets this annotation applies to. + */ + public String[] on() { + return on; + } + + /** + * Appends the targets this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(String...value) { + for (String v : value) + on = ArrayUtils.append(on, v); + return this; + } + + /** + * Implements the {@link Annotation#annotationType()} method for child classes. + * + * @return This class. + */ + @SuppressWarnings("unchecked") + public Class<? extends Annotation> annotationType() { + return (Class<? extends Annotation>) getClass(); + } + + /** + * An implementation of an annotation that can be applied to classes. + */ + public static class OnClass extends TargetedAnnotation { + + private Class<?>[] onClass = new Class[0]; + + /** + * The target classes this annotation applies to. + * + * @return The target classes this annotation applies to. + */ + public Class<?>[] onClass() { + return onClass; + } + + /** + * Appends the classes that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @SuppressWarnings("unchecked") + @FluentSetter + public TargetedAnnotation onClass(Class<?>...value) { + for (Class<?> v : value) + onClass = ArrayUtils.append(onClass, v); + return this; + } + + /** + * Appends the classes that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(Class<?>...value) { + for (Class<?> v : value) + on(v.getName()); + return this; + } + } + + /** + * An implementation of an annotation that can be applied to classes, methods, and fields. + */ + public static class OnClassMethodField extends OnClass { + + /** + * Appends the methods that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(Method...value) { + for (Method v : value) + on(MethodInfo.of(v).getFullName()); + return this; + } + + /** + * Appends the fields that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(Field...value) { + for (Field v : value) + on(v.getName()); + return this; + } + } + + /** + * An implementation of an annotation that can be applied to methods and fields. + */ + public static class OnMethodField extends TargetedAnnotation { + + /** + * Appends the methods that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(Method...value) { + for (Method v : value) + on(MethodInfo.of(v).getFullName()); + return this; + } + + /** + * Appends the fields that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(Field...value) { + for (Field v : value) + on(v.getName()); + return this; + } + } + + /** + * An implementation of an annotation that can be applied to classes, methods, fields, and constructors. + */ + public static class OnClassMethodFieldConstructor extends OnClassMethodField { + + /** + * Appends the constructors that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(Constructor<?>...value) { + for (Constructor<?> v : value) + on(ConstructorInfo.of(v).getFullName()); + return this; + } + } + + /** + * An implementation of an annotation that can be applied to constructors. + */ + public static class OnConstructor extends TargetedAnnotation { + + /** + * Appends the constructors that this annotation applies to. + * + * @param value The values to append. + * @return This object (for method chaining). + */ + @FluentSetter + public TargetedAnnotation on(Constructor<?>...value) { + for (Constructor<?> v : value) + on(ConstructorInfo.of(v).getFullName()); + return this; + } + } +} diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/URI.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/URI.java index 6b6825d..d1e8d4e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/URI.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/URI.java @@ -116,5 +116,17 @@ public @interface URI { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } \ No newline at end of file diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java index 2274355..84129b0 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java @@ -13,10 +13,8 @@ package org.apache.juneau.annotation; import java.lang.annotation.*; -import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link URI} annotation. @@ -25,29 +23,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class UriAnnotation implements URI { - - private String on = ""; - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link URI#on()} - */ - public UriAnnotation(String on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link URI#on()} - */ - public UriAnnotation(Class<?> on) { - on(on); - } +public class UriAnnotation extends TargetedAnnotation.OnClassMethodField implements URI { /** * Constructor. @@ -55,71 +31,10 @@ public class UriAnnotation implements URI { * @param on The initial value for the <c>on</c> property. * <br>See {@link URI#on()} */ - public UriAnnotation(Method on) { + public UriAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link URI#on()} - */ - public UriAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return URI.class; - } - - @Override - public String on() { - return on; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UriAnnotation on(String value) { - this.on = value; - return this; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UriAnnotation on(Class<?> value) { - this.on = value.getName(); - return this; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UriAnnotation on(Field value) { - this.on = value.getName(); - return this; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UriAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); - return this; - } + // <FluentSetters> + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/Csv.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/Csv.java index 2c212aa..24fb47e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/Csv.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/Csv.java @@ -114,5 +114,17 @@ public @interface Csv { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java index c79390e..b1ab9b1 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link Csv} annotation. @@ -25,9 +25,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class CsvAnnotation implements Csv { - - private String on = ""; +public class CsvAnnotation extends TargetedAnnotation.OnClassMethodField implements Csv { /** * Constructor. @@ -35,91 +33,41 @@ public class CsvAnnotation implements Csv { * @param on The initial value for the <c>on</c> property. * <br>See {@link Csv#on()} */ - public CsvAnnotation(String on) { + public CsvAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Csv#on()} - */ - public CsvAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Csv#on()} - */ - public CsvAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Csv#on()} - */ - public CsvAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Csv.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public CsvAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public CsvAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public CsvAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public CsvAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public CsvAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public CsvAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public CsvAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public CsvAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public CsvAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/Html.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/Html.java index d8505e1..02c146a 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/Html.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/Html.java @@ -185,7 +185,19 @@ public @interface Html { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * Associates an {@link HtmlRender} with a bean property for custom HTML rendering of the property. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java index 1b8fb2c..8ba2c9f 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java @@ -16,8 +16,8 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; +import org.apache.juneau.annotation.*; import org.apache.juneau.html.*; -import org.apache.juneau.reflect.*; /** * A concrete implementation of the {@link Html} annotation. @@ -27,10 +27,9 @@ import org.apache.juneau.reflect.*; * </ul> */ @SuppressWarnings("rawtypes") -public class HtmlAnnotation implements Html { +public class HtmlAnnotation extends TargetedAnnotation.OnClassMethodField implements Html { private String - on = "", anchorText = "", link = ""; private HtmlFormat @@ -47,45 +46,10 @@ public class HtmlAnnotation implements Html { * @param on The initial value for the <c>on</c> property. * <br>See {@link Html#on()} */ - public HtmlAnnotation(String on) { + public HtmlAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Html#on()} - */ - public HtmlAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Html#on()} - */ - public HtmlAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Html#on()} - */ - public HtmlAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Html.class; - } - @Override public String anchorText() { return anchorText; @@ -167,67 +131,52 @@ public class HtmlAnnotation implements Html { } @Override - public String on() { - return on; + public Class<? extends HtmlRender> render() { + return render; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>render</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public HtmlAnnotation on(String value) { - this.on = value; + public HtmlAnnotation render(Class<? extends HtmlRender> value) { + this.render = value; return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public HtmlAnnotation on(Class<?> value) { - this.on = value.getName(); + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public HtmlAnnotation on(String...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public HtmlAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClass */ + public HtmlAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public HtmlAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public HtmlAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - @Override - public Class<? extends HtmlRender> render() { - return render; + @Override /* GENERATED - OnClassMethodField */ + public HtmlAnnotation on(Field...value) { + super.on(value); + return this; } - /** - * Sets the <c>render</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public HtmlAnnotation render(Class<? extends HtmlRender> value) { - this.render = value; + @Override /* GENERATED - OnClassMethodField */ + public HtmlAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLink.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLink.java index 1548be3..e88a13c 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLink.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLink.java @@ -69,7 +69,19 @@ public @interface HtmlLink { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * The bean property whose value becomes the url in the hyperlink. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java index ff3b962..b0d6f2d 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java @@ -15,6 +15,7 @@ package org.apache.juneau.html.annotation; import java.lang.annotation.*; import org.apache.juneau.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link HtmlLink} annotation. @@ -23,10 +24,9 @@ import org.apache.juneau.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class HtmlLinkAnnotation implements HtmlLink { +public class HtmlLinkAnnotation extends TargetedAnnotation.OnClass implements HtmlLink { private String - on = "", nameProperty = "", uriProperty = ""; @@ -36,52 +36,10 @@ public class HtmlLinkAnnotation implements HtmlLink { * @param on The initial value for the <c>on</c> property. * <br>See {@link HtmlLink#on()} */ - public HtmlLinkAnnotation(String on) { + public HtmlLinkAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link HtmlLink#on()} - */ - public HtmlLinkAnnotation(Class<?> on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return HtmlLink.class; - } - - @Override - public String on() { - return on; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public HtmlLinkAnnotation on(String value) { - this.on = value; - return this; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public HtmlLinkAnnotation on(Class<?> value) { - this.on = value.getName(); - return this; - } - @Override public String nameProperty() { return nameProperty; @@ -113,4 +71,26 @@ public class HtmlLinkAnnotation implements HtmlLink { this.uriProperty = value; return this; } + + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public HtmlLinkAnnotation on(String...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnClass */ + public HtmlLinkAnnotation on(java.lang.Class<?>...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnClass */ + public HtmlLinkAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); + return this; + } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java index 5d725f0..72648e2 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/AnnotationUtils.java @@ -133,8 +133,8 @@ public class AnnotationUtils { if (a == null) return true; return - allEmpty(a.value(), a.description(), a.d(), a._default(), a.df(), a._enum(), a.e(), a.allOf(), a.properties(), a.additionalProperties(), a.xml(), a.example(), a.ex(), a.examples(), a.exs()) - && allEmpty(a.$ref(), a.format(), a.f(), a.title(), a.multipleOf(), a.mo(), a.maximum(), a.max(), a.minimum(), a.min(), a.pattern(), a.p(), a.type(), a.t(), a.discriminator(), a.collectionFormat(), a.cf(), a.on()) + allEmpty(a.value(), a.description(), a.d(), a._default(), a.df(), a._enum(), a.e(), a.allOf(), a.properties(), a.additionalProperties(), a.xml(), a.example(), a.ex(), a.examples(), a.exs(), a.on()) + && allEmpty(a.$ref(), a.format(), a.f(), a.title(), a.multipleOf(), a.mo(), a.maximum(), a.max(), a.minimum(), a.min(), a.pattern(), a.p(), a.type(), a.t(), a.discriminator(), a.collectionFormat(), a.cf()) && allMinusOne(a.maxProperties(), a.maxp(), a.minProperties(), a.minp()) && allFalse(a.ignore(), a.exclusiveMaximum(), a.emax(), a.exclusiveMinimum(), a.emin(), a.readOnly(), a.ro(), a.required(), a.r(), a.uniqueItems(), a.ui()) && allMinusOne(a.maxLength(), a.maxl(), a.minLength(), a.minl(), a.maxItems(), a.maxi(), a.minItems(), a.mini()) diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/Jso.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/Jso.java index 2c0574b..1d23de6 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/Jso.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/Jso.java @@ -114,5 +114,17 @@ public @interface Jso { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java index fc0b303..511cf13 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link Jso} annotation. @@ -25,9 +25,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class JsoAnnotation implements Jso { - - private String on = ""; +public class JsoAnnotation extends TargetedAnnotation.OnClassMethodField implements Jso { /** * Constructor. @@ -35,91 +33,41 @@ public class JsoAnnotation implements Jso { * @param on The initial value for the <c>on</c> property. * <br>See {@link Jso#on()} */ - public JsoAnnotation(String on) { + public JsoAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Jso#on()} - */ - public JsoAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Jso#on()} - */ - public JsoAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Jso#on()} - */ - public JsoAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Jso.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public JsoAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsoAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public JsoAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsoAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public JsoAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsoAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public JsoAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsoAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public JsoAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/Json.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/Json.java index f92eb18..29fd8ee 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/Json.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/Json.java @@ -119,7 +119,19 @@ public @interface Json { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * Wraps beans in a JSON object with the specified attribute name. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java index 9c32c33..c9a2960 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link Json} annotation. @@ -25,9 +25,8 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class JsonAnnotation implements Json { +public class JsonAnnotation extends TargetedAnnotation.OnClassMethodField implements Json { - private String on = ""; private String wrapperAttr = ""; /** @@ -36,108 +35,57 @@ public class JsonAnnotation implements Json { * @param on The initial value for the <c>on</c> property. * <br>See {@link Json#on()} */ - public JsonAnnotation(String on) { + public JsonAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Json#on()} - */ - public JsonAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Json#on()} - */ - public JsonAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Json#on()} - */ - public JsonAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Json.class; - } - @Override - public String on() { - return on; + public String wrapperAttr() { + return wrapperAttr; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>wrapperAttr</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public JsonAnnotation on(String value) { - this.on = value; + public JsonAnnotation wrapperAttr(String value) { + this.wrapperAttr = value; return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsonAnnotation on(Class<?> value) { - this.on = value.getName(); + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public JsonAnnotation on(String...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsonAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClass */ + public JsonAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsonAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public JsonAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - @Override - public String wrapperAttr() { - return wrapperAttr; + @Override /* GENERATED - OnClassMethodField */ + public JsonAnnotation on(Field...value) { + super.on(value); + return this; } - /** - * Sets the <c>wrapperAttr</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public JsonAnnotation wrapperAttr(String value) { - this.wrapperAttr = value; + @Override /* GENERATED - OnClassMethodField */ + public JsonAnnotation on(Method...value) { + super.on(value); return this; } + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/Schema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/Schema.java index e25e3ca..2745694 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/Schema.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/Schema.java @@ -911,5 +911,17 @@ public @interface Schema { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java index 171a11e..42390e8 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java @@ -13,8 +13,10 @@ package org.apache.juneau.jsonschema.annotation; import java.lang.annotation.*; +import java.lang.reflect.*; import org.apache.juneau.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link Schema} annotation. @@ -22,9 +24,7 @@ import org.apache.juneau.*; * <p> * Annotations can be applied programmatically using {@link BeanContextBuilder#annotations(Annotation...)}. */ -public class SchemaAnnotation implements Schema { - - private String on = ""; +public class SchemaAnnotation extends TargetedAnnotation.OnClassMethodField implements Schema { private String $ref = "", @@ -99,18 +99,8 @@ public class SchemaAnnotation implements Schema { * @param on The initial value for the <c>on</c> property. * <br>See {@link Schema#on()} */ - public SchemaAnnotation(String on) { - this.on = on; - } - - /** - * Constructor. - */ - public SchemaAnnotation() {} - - @Override - public Class<? extends Annotation> annotationType() { - return Schema.class; + public SchemaAnnotation(String...on) { + on(on); } @Override /* Schema */ @@ -802,22 +792,6 @@ public class SchemaAnnotation implements Schema { } @Override /* Schema */ - public String on() { - return on; - } - - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SchemaAnnotation on(String value) { - this.on = value; - return this; - } - - @Override /* Schema */ public String pattern() { return pattern; } @@ -1040,4 +1014,38 @@ public class SchemaAnnotation implements Schema { this.xml = value; return this; } + + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public SchemaAnnotation on(String...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnClass */ + public SchemaAnnotation on(java.lang.Class<?>...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnClass */ + public SchemaAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); + return this; + } + + @Override /* GENERATED - OnClassMethodField */ + public SchemaAnnotation on(Field...value) { + super.on(value); + return this; + } + + @Override /* GENERATED - OnClassMethodField */ + public SchemaAnnotation on(Method...value) { + super.on(value); + return this; + } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPack.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPack.java index 1417155..665ec3f 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPack.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPack.java @@ -114,5 +114,17 @@ public @interface MsgPack { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java index e3195f3..100d030 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link MsgPack} annotation. @@ -25,9 +25,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class MsgPackAnnotation implements MsgPack { - - private String on = ""; +public class MsgPackAnnotation extends TargetedAnnotation.OnClassMethodField implements MsgPack { /** * Constructor. @@ -35,91 +33,41 @@ public class MsgPackAnnotation implements MsgPack { * @param on The initial value for the <c>on</c> property. * <br>See {@link MsgPack#on()} */ - public MsgPackAnnotation(String on) { + public MsgPackAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link MsgPack#on()} - */ - public MsgPackAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link MsgPack#on()} - */ - public MsgPackAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link MsgPack#on()} - */ - public MsgPackAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return MsgPack.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public MsgPackAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public MsgPackAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public MsgPackAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public MsgPackAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public MsgPackAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public MsgPackAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public MsgPackAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public MsgPackAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public MsgPackAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApi.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApi.java index 4f2b185..742ef82 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApi.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApi.java @@ -114,5 +114,17 @@ public @interface OpenApi { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java index b0c1985..0517197 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link OpenApi} annotation. @@ -25,9 +25,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class OpenApiAnnotation implements OpenApi { - - private String on = ""; +public class OpenApiAnnotation extends TargetedAnnotation.OnClassMethodField implements OpenApi { /** * Constructor. @@ -35,91 +33,41 @@ public class OpenApiAnnotation implements OpenApi { * @param on The initial value for the <c>on</c> property. * <br>See {@link OpenApi#on()} */ - public OpenApiAnnotation(String on) { + public OpenApiAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link OpenApi#on()} - */ - public OpenApiAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link OpenApi#on()} - */ - public OpenApiAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link OpenApi#on()} - */ - public OpenApiAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return OpenApi.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public OpenApiAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public OpenApiAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public OpenApiAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public OpenApiAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public OpenApiAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public OpenApiAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public OpenApiAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public OpenApiAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public OpenApiAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainText.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainText.java index 9aa82a0..a4551e4 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainText.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainText.java @@ -114,5 +114,17 @@ public @interface PlainText { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java index 3f900ea..ce87e03 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link PlainText} annotation. @@ -25,9 +25,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class PlainTextAnnotation implements PlainText { - - private String on = ""; +public class PlainTextAnnotation extends TargetedAnnotation.OnClassMethodField implements PlainText { /** * Constructor. @@ -35,91 +33,41 @@ public class PlainTextAnnotation implements PlainText { * @param on The initial value for the <c>on</c> property. * <br>See {@link PlainText#on()} */ - public PlainTextAnnotation(String on) { + public PlainTextAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link PlainText#on()} - */ - public PlainTextAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link PlainText#on()} - */ - public PlainTextAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link PlainText#on()} - */ - public PlainTextAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return PlainText.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public PlainTextAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public PlainTextAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public PlainTextAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public PlainTextAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public PlainTextAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public PlainTextAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public PlainTextAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public PlainTextAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public PlainTextAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXml.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXml.java index 660c09b..c92e4c9 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXml.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXml.java @@ -114,5 +114,17 @@ public @interface SoapXml { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java index 0038ca3..25e6f28 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link SoapXml} annotation. @@ -25,9 +25,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class SoapXmlAnnotation implements SoapXml { - - private String on = ""; +public class SoapXmlAnnotation extends TargetedAnnotation.OnClassMethodField implements SoapXml { /** * Constructor. @@ -35,91 +33,41 @@ public class SoapXmlAnnotation implements SoapXml { * @param on The initial value for the <c>on</c> property. * <br>See {@link SoapXml#on()} */ - public SoapXmlAnnotation(String on) { + public SoapXmlAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link SoapXml#on()} - */ - public SoapXmlAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link SoapXml#on()} - */ - public SoapXmlAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link SoapXml#on()} - */ - public SoapXmlAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return SoapXml.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public SoapXmlAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SoapXmlAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public SoapXmlAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SoapXmlAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public SoapXmlAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SoapXmlAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public SoapXmlAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public SoapXmlAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public SoapXmlAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/Uon.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/Uon.java index 6817bb1..02e4ca0 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/Uon.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/Uon.java @@ -114,5 +114,17 @@ public @interface Uon { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java index c014989..32207c8 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link Uon} annotation. @@ -25,9 +25,7 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class UonAnnotation implements Uon { - - private String on = ""; +public class UonAnnotation extends TargetedAnnotation.OnClassMethodField implements Uon { /** * Constructor. @@ -35,91 +33,41 @@ public class UonAnnotation implements Uon { * @param on The initial value for the <c>on</c> property. * <br>See {@link Uon#on()} */ - public UonAnnotation(String on) { + public UonAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Uon#on()} - */ - public UonAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Uon#on()} - */ - public UonAnnotation(Method on) { - on(on); - } + // <FluentSetters> - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Uon#on()} - */ - public UonAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Uon.class; - } - - @Override - public String on() { - return on; + @Override /* GENERATED - TargetedAnnotation */ + public UonAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UonAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public UonAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UonAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public UonAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UonAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public UonAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UonAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public UonAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncoding.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncoding.java index 499fe39..6b76816 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncoding.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncoding.java @@ -121,5 +121,17 @@ public @interface UrlEncoding { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; } diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java index 812cfd6..705e106 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link UrlEncoding} annotation. @@ -25,10 +25,8 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class UrlEncodingAnnotation implements UrlEncoding { +public class UrlEncodingAnnotation extends TargetedAnnotation.OnClassMethodField implements UrlEncoding { - private String - on = ""; private boolean expandedParams = false; @@ -38,46 +36,11 @@ public class UrlEncodingAnnotation implements UrlEncoding { * @param on The initial value for the <c>on</c> property. * <br>See {@link UrlEncoding#on()} */ - public UrlEncodingAnnotation(String on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link UrlEncoding#on()} - */ - public UrlEncodingAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link UrlEncoding#on()} - */ - public UrlEncodingAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link UrlEncoding#on()} - */ - public UrlEncodingAnnotation(Field on) { + public UrlEncodingAnnotation(String...on) { on(on); } @Override - public Class<? extends Annotation> annotationType() { - return UrlEncoding.class; - } - - @Override public boolean expandedParams() { return expandedParams; } @@ -93,52 +56,37 @@ public class UrlEncodingAnnotation implements UrlEncoding { return this; } - @Override - public String on() { - return on; + // <FluentSetters> + + @Override /* GENERATED - TargetedAnnotation */ + public UrlEncodingAnnotation on(String...value) { + super.on(value); + return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UrlEncodingAnnotation on(String value) { - this.on = value; + @Override /* GENERATED - OnClass */ + public UrlEncodingAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UrlEncodingAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public UrlEncodingAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UrlEncodingAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClassMethodField */ + public UrlEncodingAnnotation on(Field...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public UrlEncodingAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClassMethodField */ + public UrlEncodingAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } \ No newline at end of file diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/Xml.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/Xml.java index 4129063..2445497 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/Xml.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/Xml.java @@ -216,7 +216,19 @@ public @interface Xml { * <li class='link'>{@doc DynamicallyAppliedAnnotations} * </ul> */ - String on() default ""; + String[] on() default {}; + + /** + * Dynamically apply this annotation to the specified classes. + * + * <p> + * Identical to {@link #on()} except allows you to specify class objects instead of a strings. + * + * <ul class='seealso'> + * <li class='link'>{@doc DynamicallyAppliedAnnotations} + * </ul> + */ + Class<?>[] onClass() default {}; /** * Sets the XML prefix of this property or class. diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java index 956c5bb..80f2074 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java @@ -16,7 +16,7 @@ import java.lang.annotation.*; import java.lang.reflect.*; import org.apache.juneau.*; -import org.apache.juneau.reflect.*; +import org.apache.juneau.annotation.*; /** * A concrete implementation of the {@link Xml} annotation. @@ -25,10 +25,9 @@ import org.apache.juneau.reflect.*; * <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)} * </ul> */ -public class XmlAnnotation implements Xml { +public class XmlAnnotation extends TargetedAnnotation.OnClassMethodField implements Xml { private String - on = "", childName = "", namespace = "", prefix = ""; @@ -41,45 +40,10 @@ public class XmlAnnotation implements Xml { * @param on The initial value for the <c>on</c> property. * <br>See {@link Xml#on()} */ - public XmlAnnotation(String on) { + public XmlAnnotation(String...on) { on(on); } - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Xml#on()} - */ - public XmlAnnotation(Class<?> on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Xml#on()} - */ - public XmlAnnotation(Method on) { - on(on); - } - - /** - * Constructor. - * - * @param on The initial value for the <c>on</c> property. - * <br>See {@link Xml#on()} - */ - public XmlAnnotation(Field on) { - on(on); - } - - @Override - public Class<? extends Annotation> annotationType() { - return Xml.class; - } - @Override public String childName() { return childName; @@ -129,68 +93,52 @@ public class XmlAnnotation implements Xml { } @Override - public String on() { - return on; + public String prefix() { + return prefix; } /** - * Sets the <c>on</c> property on this annotation. + * Sets the <c>prefix</c> property on this annotation. * * @param value The new value for this property. * @return This object (for method chaining). */ - public XmlAnnotation on(String value) { - this.on = value; + public XmlAnnotation prefix(String value) { + this.prefix = value; return this; } + // <FluentSetters> - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public XmlAnnotation on(Class<?> value) { - this.on = value.getName(); + @Override /* GENERATED - TargetedAnnotation */ + public XmlAnnotation on(String...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public XmlAnnotation on(Method value) { - this.on = MethodInfo.of(value).getFullName(); + @Override /* GENERATED - OnClass */ + public XmlAnnotation on(java.lang.Class<?>...value) { + super.on(value); return this; } - /** - * Sets the <c>on</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public XmlAnnotation on(Field value) { - this.on = value.getName(); + @Override /* GENERATED - OnClass */ + public XmlAnnotation onClass(java.lang.Class<?>...value) { + super.onClass(value); return this; } - @Override - public String prefix() { - return prefix; + @Override /* GENERATED - OnClassMethodField */ + public XmlAnnotation on(Field...value) { + super.on(value); + return this; } - /** - * Sets the <c>prefix</c> property on this annotation. - * - * @param value The new value for this property. - * @return This object (for method chaining). - */ - public XmlAnnotation prefix(String value) { - this.prefix = value; + @Override /* GENERATED - OnClassMethodField */ + public XmlAnnotation on(Method...value) { + super.on(value); return this; } + + // </FluentSetters> } diff --git a/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java b/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java index c3bd758..31a0716 100644 --- a/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java +++ b/juneau-releng/juneau-all/src/java/main/ConfigurablePropertyCodeGenerator.java @@ -17,33 +17,47 @@ import java.util.*; import java.util.stream.*; import org.apache.juneau.*; +import org.apache.juneau.annotation.*; import org.apache.juneau.assertions.*; import org.apache.juneau.collections.*; import org.apache.juneau.config.*; import org.apache.juneau.config.store.*; import org.apache.juneau.csv.*; +import org.apache.juneau.csv.annotation.*; import org.apache.juneau.html.*; +import org.apache.juneau.html.annotation.*; import org.apache.juneau.http.*; import org.apache.juneau.http.exception.*; import org.apache.juneau.http.response.*; import org.apache.juneau.internal.*; import org.apache.juneau.jena.*; +import org.apache.juneau.jena.annotation.*; import org.apache.juneau.jso.*; +import org.apache.juneau.jso.annotation.*; import org.apache.juneau.json.*; +import org.apache.juneau.json.annotation.*; import org.apache.juneau.jsonschema.*; +import org.apache.juneau.jsonschema.annotation.*; import org.apache.juneau.msgpack.*; +import org.apache.juneau.msgpack.annotation.*; import org.apache.juneau.oapi.*; +import org.apache.juneau.oapi.annotation.*; import org.apache.juneau.parser.*; import org.apache.juneau.plaintext.*; +import org.apache.juneau.plaintext.annotation.*; import org.apache.juneau.reflect.*; import org.apache.juneau.rest.*; import org.apache.juneau.rest.client.*; import org.apache.juneau.rest.mock.*; import org.apache.juneau.serializer.*; import org.apache.juneau.soap.*; +import org.apache.juneau.soap.annotation.*; import org.apache.juneau.uon.*; +import org.apache.juneau.uon.annotation.*; import org.apache.juneau.urlencoding.*; +import org.apache.juneau.urlencoding.annotation.*; import org.apache.juneau.xml.*; +import org.apache.juneau.xml.annotation.*; public class ConfigurablePropertyCodeGenerator { @@ -200,7 +214,38 @@ public class ConfigurablePropertyCodeGenerator { ExecutableInfo.class, ConstructorInfo.class, - MethodInfo.class + MethodInfo.class, + + TargetedAnnotation.class, + TargetedAnnotation.OnClass.class, + TargetedAnnotation.OnClassMethodField.class, + TargetedAnnotation.OnConstructor.class, + TargetedAnnotation.OnMethodField.class, + TargetedAnnotation.OnClassMethodFieldConstructor.class, + BeanAnnotation.class, + BeancAnnotation.class, + BeanIgnoreAnnotation.class, + BeanpAnnotation.class, + ExampleAnnotation.class, + NamePropertyAnnotation.class, + ParentPropertyAnnotation.class, + SwapAnnotation.class, + UriAnnotation.class, + CsvAnnotation.class, + HtmlAnnotation.class, + HtmlLinkAnnotation.class, + JsoAnnotation.class, + JsonAnnotation.class, + SchemaAnnotation.class, + MsgPackAnnotation.class, + OpenApiAnnotation.class, + PlainTextAnnotation.class, + SoapXmlAnnotation.class, + UonAnnotation.class, + UrlEncodingAnnotation.class, + XmlAnnotation.class, + RdfAnnotation.class + }; static Set<Class<?>> ignoreClasses = ASet.of( @@ -233,6 +278,8 @@ public class ConfigurablePropertyCodeGenerator { for (Class<?> c : classes) { File f = findClassFile(c); + if (f == null) + continue; System.out.println("Processing " + f.getName()); String s = IOUtils.read(f); @@ -371,7 +418,7 @@ public class ConfigurablePropertyCodeGenerator { if (f.exists()) return f; } - throw new RuntimeException("Could not find source for class " + c.getName()); + return null; } private static class MethodComparator implements Comparator<Method> {