You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2026/04/13 13:12:27 UTC
(juneau) branch master updated: Moving schema annotations into juneau-common
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 d4792d3cd7 Moving schema annotations into juneau-common
d4792d3cd7 is described below
commit d4792d3cd762b9c8341b02a5b10e465645926f43
Author: James Bognar <ja...@jamesbog-ltmjqf2.internal.salesforce.com>
AuthorDate: Mon Apr 13 09:12:19 2026 -0400
Moving schema annotations into juneau-common
---
.../java/org/apache/juneau/annotation/Schema.java | 7 +-
.../org/apache/juneau/hjson/HjsonSerializer.java | 2 +-
.../juneau/http/annotation/ContentAnnotation.java | 262 --------------
.../juneau/http/annotation/FormDataAnnotation.java | 386 --------------------
.../http/annotation/HasFormDataAnnotation.java | 143 --------
.../juneau/http/annotation/HeaderAnnotation.java | 386 --------------------
.../juneau/http/annotation/PathAnnotation.java | 387 --------------------
.../http/annotation/PathRemainderAnnotation.java | 340 ------------------
.../juneau/http/annotation/QueryAnnotation.java | 390 ---------------------
.../juneau/http/annotation/RequestAnnotation.java | 239 -------------
.../juneau/http/annotation/ResponseAnnotation.java | 320 -----------------
.../http/annotation/StatusCodeAnnotation.java | 233 ------------
.../juneau/httppart/HttpPartMarshalling.java | 64 ++++
.../org/apache/juneau/httppart/HttpPartSchema.java | 250 ++++++-------
.../apache/juneau/httppart/HttpPartSerializer.java | 8 +-
.../ng/rest/client/remote/NgRemoteClient.java | 30 +-
.../http/annotation/CollectionFormatType.java | 0
.../org/apache/juneau/http/annotation/Contact.java | 0
.../juneau/http/annotation/ContactAnnotation.java | 10 +-
.../org/apache/juneau/http/annotation/Content.java | 32 +-
.../apache/juneau/http/annotation/FormData.java | 51 +--
.../apache/juneau/http/annotation/FormatType.java | 0
.../apache/juneau/http/annotation/HasFormData.java | 0
.../apache/juneau/http/annotation/HasQuery.java | 0
.../org/apache/juneau/http/annotation/Header.java | 51 +--
.../org/apache/juneau/http/annotation/License.java | 0
.../juneau/http/annotation/LicenseAnnotation.java | 10 +-
.../juneau/http/annotation/ParameterType.java | 0
.../org/apache/juneau/http/annotation/Path.java | 51 +--
.../juneau/http/annotation/PathRemainder.java | 50 +--
.../org/apache/juneau/http/annotation/Query.java | 51 +--
.../org/apache/juneau/http/annotation/Request.java | 50 ---
.../apache/juneau/http/annotation/Response.java | 50 +--
.../juneau/http/annotation/ResponseAnnotation.java | 94 +++--
.../apache/juneau/http/annotation/StatusCode.java | 28 --
.../org/apache/juneau/http/annotation/Tag.java | 0
.../juneau/http/annotation/TagAnnotation.java | 10 +-
.../http/annotation/doc-files/Body_Example.png | Bin
.../http/annotation/doc-files/Body_Swagger.png | Bin
.../juneau/http/annotation/package-info.java | 0
.../apache/juneau/http/remote/RemoteReturn.java | 6 +-
.../juneau/httppart/bean/MethodInfoUtils.java | 0
.../juneau/httppart/bean/RequestBeanMeta.java | 11 +-
.../httppart/bean/RequestBeanPropertyMeta.java | 0
.../juneau/httppart/bean/ResponseBeanMeta.java | 5 +-
.../httppart/bean/ResponseBeanPropertyMeta.java | 0
.../apache/juneau/httppart/bean/package-info.java | 0
.../org/apache/juneau/ng/http/remote/Body.java | 55 ---
.../org/apache/juneau/ng/http/remote/Header.java | 52 ---
.../org/apache/juneau/ng/http/remote/Path.java | 55 ---
.../org/apache/juneau/ng/http/remote/Query.java | 52 ---
.../org/apache/juneau/rest/arg/FormDataArg.java | 119 +++----
.../java/org/apache/juneau/rest/arg/HeaderArg.java | 114 ++----
.../java/org/apache/juneau/rest/arg/PathArg.java | 114 ++----
.../apache/juneau/rest/arg/PathRemainderArg.java | 13 +-
.../java/org/apache/juneau/rest/arg/QueryArg.java | 110 ++----
.../apache/juneau/rest/arg/ResponseHeaderArg.java | 14 +-
.../rest/swagger/BasicSwaggerProviderSession.java | 35 +-
.../http/annotation/AnnotationUtils_Test.java | 149 +-------
.../http/annotation/ContentAnnotation_Test.java | 119 -------
.../http/annotation/FormDataAnnotation_Test.java | 146 --------
.../annotation/HasFormDataAnnotation_Test.java | 63 ----
.../http/annotation/HasQueryAnnotation_Test.java | 65 ----
.../http/annotation/HeaderAnnotation_Test.java | 146 --------
.../http/annotation/PathAnnotation_Test.java | 146 --------
.../http/annotation/QueryAnnotation_Test.java | 146 --------
.../http/annotation/RequestAnnotation_Test.java | 126 -------
.../http/annotation/ResponseAnnotation_Test.java | 60 +---
.../annotation/ResponseStatusAnnotation_Test.java | 123 -------
.../remote/Remote_FormDataAnnotation_Test.java | 27 +-
.../http/remote/Remote_HeaderAnnotation_Test.java | 27 +-
.../Remote_MethodDefaultsAnnotation_Test.java | 48 ---
.../http/remote/Remote_PathAnnotation_Test.java | 31 +-
.../http/remote/Remote_QueryAnnotation_Test.java | 27 +-
.../http/remote/Remote_RequestAnnotation_Test.java | 5 +-
.../apache/juneau/ng/rest/NgRemoteClient_Test.java | 26 +-
.../rest/test/client/ThirdPartyProxyResource.java | 8 +-
.../rest/test/client/ThirdPartyProxy_Test.java | 8 +-
todo/decouple-rest-common-from-marshall.md | 141 ++++++++
79 files changed, 712 insertions(+), 5665 deletions(-)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java
index ec0f28b8ea..db8539b76b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/Schema.java
@@ -23,7 +23,6 @@ import java.lang.annotation.*;
import java.util.*;
import org.apache.juneau.collections.*;
-import org.apache.juneau.http.annotation.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.oapi.*;
@@ -472,7 +471,7 @@ public @interface Schema {
* <br>Can only be used if <c>type</c> is <js>"array"</js>.
*
* <p>
- * Static strings are defined in {@link CollectionFormatType}.
+ * Static strings are defined in <c>CollectionFormatType</c>.
*
* <p>
* Note that for collections/arrays parameters with POJO element types, the input is broken into a string array before being converted into POJO elements.
@@ -952,7 +951,7 @@ public @interface Schema {
* The extending format for the previously mentioned <a class="doclink" href="https://swagger.io/specification/v2#parameterType">parameter type</a>.
*
* <p>
- * Static strings are defined in {@link FormatType}.
+ * Static strings are defined in <c>FormatType</c>.
*
* <h5 class='section'>Examples:</h5>
* <p class='bjava'>
@@ -1699,7 +1698,7 @@ public @interface Schema {
* </ul>
*
* <h5 class='section'>Notes:</h5><ul>
- * <li class='note'>Static strings are defined in {@link ParameterType}.
+ * <li class='note'>Static strings are defined in <c>ParameterType</c>.
* </ul>
*
* <h5 class='section'>See Also:</h5><ul>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/hjson/HjsonSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/hjson/HjsonSerializer.java
index 615b15a592..634bcf7f29 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/hjson/HjsonSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/hjson/HjsonSerializer.java
@@ -97,7 +97,7 @@ import org.apache.juneau.serializer.*;
* Use {@link Builder#omitRootBraces(boolean)} to suppress them.
* <li class='note'>In compact mode, strings containing newlines are serialized as double-quoted strings
* with JSON escape sequences rather than multiline <c>'''</c> blocks.
- * <li class='note'>Format-specific field-level annotations ({@link Hjson @Hjson}) are supported
+ * <li class='note'>Format-specific field-level annotations ({@link org.apache.juneau.hjson.annotation.Hjson @Hjson}) are supported
* but intentionally minimal in the initial implementation.
* <li class='note'>This class is thread safe and reusable.
* </ul>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ContentAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ContentAnnotation.java
deleted file mode 100644
index fb6849426c..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ContentAnnotation.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link Content @Content} annotation.
- *
- */
-public class ContentAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private ContentAnnotation() {}
-
- /**
- * Applies targeted {@link Content} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<Content,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(Content.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<Content> ai, BeanContext.Builder b) {
- Content a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link Content @Content annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- Content[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTM {
-
- private String def = "";
- private String[] description = {};
- private Schema schema = SchemaAnnotation.DEFAULT;
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(Content.class);
- }
-
- /**
- * Instantiates a new {@link Content @Content} object initialized with this builder.
- *
- * @return A new {@link Content @Content} object.
- */
- public Content build() {
- return new Object(this);
- }
-
- /**
- * Sets the {@link Content#def} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder def(String value) {
- def = value;
- return this;
- }
-
- /**
- * Sets the {@link Content#description} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link Content#schema} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder schema(Schema value) {
- schema = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTM */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements Content {
-
- private final String[] description;
- private final String def;
- private final Schema schema;
-
- Object(ContentAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- def = b.def;
- schema = b.schema;
- }
-
- @Override /* Overridden from Content */
- public String def() {
- return def;
- }
-
- @Override /* Overridden from Content */
- public Schema schema() {
- return schema;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final Content DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-
- /**
- * Returns <jk>true</jk> if the specified annotation contains all default values.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if the specified annotation contains all default values.
- */
- public static boolean empty(Content a) {
- return a == null || DEFAULT.equals(a);
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
deleted file mode 100644
index c48c5b237f..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-import static org.apache.juneau.commons.utils.StringUtils.*;
-import static org.apache.juneau.commons.utils.Utils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link FormData @FormData} annotation.
- *
- */
-public class FormDataAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private FormDataAnnotation() {}
-
- private static final AnnotationProvider AP = AnnotationProvider.INSTANCE;
-
- /**
- * Applies targeted {@link FormData} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<FormData,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(FormData.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<FormData> ai, BeanContext.Builder b) {
- var a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link FormData @FormData annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- FormData[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTMF {
-
- private String[] description = {};
- private Class<? extends HttpPartParser> parser = HttpPartParser.Void.class;
- private Class<? extends HttpPartSerializer> serializer = HttpPartSerializer.Void.class;
- private Schema schema = SchemaAnnotation.DEFAULT;
- private String def = "";
- private String name = "";
- private String value = "";
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(FormData.class);
- }
-
- /**
- * Instantiates a new {@link FormData @FormData} object initialized with this builder.
- *
- * @return A new {@link FormData @FormData} object.
- */
- public FormData build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link FormData#def} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder def(String value) {
- def = value;
- return this;
- }
-
- /**
- * Sets the {@link FormData#name} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder name(String value) {
- name = value;
- return this;
- }
-
- /**
- * Sets the {@link FormData#parser} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder parser(Class<? extends HttpPartParser> value) {
- parser = value;
- return this;
- }
-
- /**
- * Sets the {@link FormData#schema} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder schema(Schema value) {
- schema = value;
- return this;
- }
-
- /**
- * Sets the {@link FormData#serializer} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder serializer(Class<? extends HttpPartSerializer> value) {
- serializer = value;
- return this;
- }
-
- /**
- * Sets the {@link FormData#value} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder value(String value) {
- this.value = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderMF */
- public Builder on(Field...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(FieldInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements FormData {
-
- private final String[] description;
- private final Class<? extends HttpPartParser> parser;
- private final Class<? extends HttpPartSerializer> serializer;
- private final String name;
- private final String value;
- private final String def;
- private final Schema schema;
-
- Object(FormDataAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- def = b.def;
- name = b.name;
- parser = b.parser;
- schema = b.schema;
- serializer = b.serializer;
- value = b.value;
- }
-
- @Override /* Overridden from FormData */
- public String def() {
- return def;
- }
-
- @Override /* Overridden from FormData */
- public String name() {
- return name;
- }
-
- @Override /* Overridden from FormData */
- public Class<? extends HttpPartParser> parser() {
- return parser;
- }
-
- @Override /* Overridden from FormData */
- public Schema schema() {
- return schema;
- }
-
- @Override /* Overridden from FormData */
- public Class<? extends HttpPartSerializer> serializer() {
- return serializer;
- }
-
- @Override
- public String value() {
- return value;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final FormData DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-
- /**
- * Returns <jk>true</jk> if the specified annotation contains all default values.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if the specified annotation contains all default values.
- */
- public static boolean empty(FormData a) {
- return a == null || DEFAULT.equals(a);
- }
-
- /**
- * Finds the default value from the specified list of annotations.
- *
- * @param pi The parameter.
- * @return The last matching default value, or empty if not found.
- */
- public static Optional<String> findDef(ParameterInfo pi) {
- // @formatter:off
- return AP.find(FormData.class, pi)
- .stream()
- .map(AnnotationInfo::inner)
- .filter(x -> ne(x.def()))
- .findFirst()
- .map(x -> x.def());
- // @formatter:on
- }
-
- /**
- * Finds the name from the specified lists of annotations.
- *
- * <p>
- * The last matching name found is returned.
- *
- * @param pi The parameter.
- * @return The last matching name, or empty if not found.
- */
- public static Optional<String> findName(ParameterInfo pi) {
- return AP.find(FormData.class, pi).stream().map(AnnotationInfo::inner).filter(x -> isAnyNotBlank(x.value(), x.name())).findFirst().map(x -> firstNonBlank(x.name(), x.value()));
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
deleted file mode 100644
index f5fa25125e..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormDataAnnotation.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-
-import java.lang.annotation.*;
-
-import org.apache.juneau.commons.annotation.*;
-
-/**
- * Utility classes and methods for the {@link HasFormData @HasFormData} annotation.
- *
- */
-public class HasFormDataAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private HasFormDataAnnotation() {}
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AnnotationObject.Builder {
-
- private String[] description = {};
- private String name = "";
- private String value = "";
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(HasFormData.class);
- }
-
- /**
- * Instantiates a new {@link HasFormData @HasFormData} object initialized with this builder.
- *
- * @return A new {@link HasFormData @HasFormData} object.
- */
- public HasFormData build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link HasFormData#name} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder name(String value) {
- name = value;
- return this;
- }
-
- /**
- * Sets the {@link HasFormData#value} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder value(String value) {
- this.value = value;
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AnnotationObject implements HasFormData {
-
- private final String[] description;
- private final String name;
- private final String value;
-
- Object(HasFormDataAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- name = b.name;
- value = b.value;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public String value() {
- return value;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final HasFormData DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
deleted file mode 100644
index 072a5f6f96..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-import static org.apache.juneau.commons.utils.StringUtils.*;
-import static org.apache.juneau.commons.utils.Utils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link Header @Header} annotation.
- *
- */
-public class HeaderAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private HeaderAnnotation() {}
-
- private static final AnnotationProvider AP = AnnotationProvider.INSTANCE;
-
- /**
- * Applies targeted {@link Header} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<Header,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(Header.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<Header> ai, BeanContext.Builder b) {
- var a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link Header @Header annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- Header[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTMF {
-
- private String[] description = {};
- private Class<? extends HttpPartParser> parser = HttpPartParser.Void.class;
- private Class<? extends HttpPartSerializer> serializer = HttpPartSerializer.Void.class;
- private Schema schema = SchemaAnnotation.DEFAULT;
- private String name = "";
- private String value = "";
- private String def = "";
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(Header.class);
- }
-
- /**
- * Instantiates a new {@link Header @Header} object initialized with this builder.
- *
- * @return A new {@link Header @Header} object.
- */
- public Header build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link Header#def} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder def(String value) {
- def = value;
- return this;
- }
-
- /**
- * Sets the {@link Header#name} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder name(String value) {
- name = value;
- return this;
- }
-
- /**
- * Sets the {@link Header#parser} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder parser(Class<? extends HttpPartParser> value) {
- parser = value;
- return this;
- }
-
- /**
- * Sets the {@link Header#schema} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder schema(Schema value) {
- schema = value;
- return this;
- }
-
- /**
- * Sets the {@link Header#serializer} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder serializer(Class<? extends HttpPartSerializer> value) {
- serializer = value;
- return this;
- }
-
- /**
- * Sets the {@link Header#value} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder value(String value) {
- this.value = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderMF */
- public Builder on(Field...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(FieldInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements Header {
-
- private final String[] description;
- private final Class<? extends HttpPartParser> parser;
- private final Class<? extends HttpPartSerializer> serializer;
- private final String name;
- private final String value;
- private final String def;
- private final Schema schema;
-
- Object(HeaderAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- def = b.def;
- name = b.name;
- parser = b.parser;
- schema = b.schema;
- serializer = b.serializer;
- value = b.value;
- }
-
- @Override /* Overridden from Header */
- public String def() {
- return def;
- }
-
- @Override /* Overridden from Header */
- public String name() {
- return name;
- }
-
- @Override /* Overridden from Header */
- public Class<? extends HttpPartParser> parser() {
- return parser;
- }
-
- @Override /* Overridden from Header */
- public Schema schema() {
- return schema;
- }
-
- @Override /* Overridden from Header */
- public Class<? extends HttpPartSerializer> serializer() {
- return serializer;
- }
-
- @Override /* Overridden from Header */
- public String value() {
- return value;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final Header DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-
- /**
- * Returns <jk>true</jk> if the specified annotation contains all default values.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if the specified annotation contains all default values.
- */
- public static boolean empty(Header a) {
- return a == null || DEFAULT.equals(a);
- }
-
- /**
- * Finds the default value from the specified list of annotations.
- *
- * @param pi The parameter.
- * @return The last matching default value, or empty if not found.
- */
- public static Optional<String> findDef(ParameterInfo pi) {
- // @formatter:off
- return AP.find(Header.class, pi)
- .stream()
- .map(AnnotationInfo::inner)
- .filter(x -> ne(x.def()))
- .findFirst()
- .map(Header::def);
- // @formatter:on
- }
-
- /**
- * Finds the name from the specified lists of annotations.
- *
- * <p>
- * The last matching name found is returned.
- *
- * @param pi The parameter.
- * @return The last matching name, or empty if not found.
- */
- public static Optional<String> findName(ParameterInfo pi) {
- return AP.find(Header.class, pi).stream().map(AnnotationInfo::inner).filter(x -> isAnyNotBlank(x.value(), x.name())).findFirst().map(x -> firstNonBlank(x.name(), x.value()));
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
deleted file mode 100644
index 99451a5a84..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.Constants.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-import static org.apache.juneau.commons.utils.StringUtils.*;
-import static org.apache.juneau.commons.utils.Utils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link Path @Path} annotation.
- *
- */
-public class PathAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private PathAnnotation() {}
-
- private static final AnnotationProvider AP = AnnotationProvider.INSTANCE;
-
- /**
- * Applies targeted {@link Path} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<Path,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(Path.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<Path> ai, BeanContext.Builder b) {
- Path a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link Path @Path annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- Path[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTMF {
-
- private String[] description = {};
- private Class<? extends HttpPartParser> parser = HttpPartParser.Void.class;
- private Class<? extends HttpPartSerializer> serializer = HttpPartSerializer.Void.class;
- private Schema schema = SchemaAnnotation.DEFAULT;
- private String name = "";
- private String value = "";
- private String def = NONE;
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(Path.class);
- }
-
- /**
- * Instantiates a new {@link Path @Path} object initialized with this builder.
- *
- * @return A new {@link Path @Path} object.
- */
- public Path build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link Path#name} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder def(String value) {
- def = value;
- return this;
- }
-
- /**
- * Sets the {@link Path#name} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder name(String value) {
- name = value;
- return this;
- }
-
- /**
- * Sets the {@link Path#parser} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder parser(Class<? extends HttpPartParser> value) {
- parser = value;
- return this;
- }
-
- /**
- * Sets the {@link Path#schema} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder schema(Schema value) {
- schema = value;
- return this;
- }
-
- /**
- * Sets the {@link Path#serializer} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder serializer(Class<? extends HttpPartSerializer> value) {
- serializer = value;
- return this;
- }
-
- /**
- * Sets the {@link Path#value} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder value(String value) {
- this.value = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderMF */
- public Builder on(Field...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(FieldInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements Path {
-
- private final String[] description;
- private final Class<? extends HttpPartParser> parser;
- private final Class<? extends HttpPartSerializer> serializer;
- private final String name;
- private final String value;
- private final String def;
- private final Schema schema;
-
- Object(PathAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- def = b.def;
- name = b.name;
- parser = b.parser;
- schema = b.schema;
- serializer = b.serializer;
- value = b.value;
- }
-
- @Override /* Overridden from Path */
- public String def() {
- return def;
- }
-
- @Override /* Overridden from Path */
- public String name() {
- return name;
- }
-
- @Override /* Overridden from Path */
- public Class<? extends HttpPartParser> parser() {
- return parser;
- }
-
- @Override /* Overridden from Path */
- public Schema schema() {
- return schema;
- }
-
- @Override /* Overridden from Path */
- public Class<? extends HttpPartSerializer> serializer() {
- return serializer;
- }
-
- @Override /* Overridden from Path */
- public String value() {
- return value;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final Path DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-
- /**
- * Returns <jk>true</jk> if the specified annotation contains all default values.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if the specified annotation contains all default values.
- */
- public static boolean empty(Path a) {
- return a == null || DEFAULT.equals(a);
- }
-
- /**
- * Finds the default value from the specified list of annotations.
- *
- * @param pi The parameter.
- * @return The last matching default value, or empty if not found.
- */
- public static Optional<String> findDef(ParameterInfo pi) {
- // @formatter:off
- return AP.find(Header.class, pi)
- .stream()
- .map(AnnotationInfo::inner)
- .filter(x -> ne(x.def()) && neq(NONE, x.def()))
- .findFirst()
- .map(Header::def);
- // @formatter:on
- }
-
- /**
- * Finds the name from the specified lists of annotations.
- *
- * <p>
- * The last matching name found is returned.
- *
- * @param pi The parameter.
- * @return The last matching name, or empty if not found.
- */
- public static Optional<String> findName(ParameterInfo pi) {
- return AP.find(Path.class, pi).stream().map(AnnotationInfo::inner).filter(x -> isAnyNotBlank(x.value(), x.name())).findFirst().map(x -> firstNonBlank(x.name(), x.value()));
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainderAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainderAnnotation.java
deleted file mode 100644
index 9f63f5057c..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainderAnnotation.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-import static org.apache.juneau.commons.utils.Utils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link PathRemainder @PathRemainder} annotation.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='ja'>{@link PathRemainder}
- * <li class='ja'>{@link Path}
- * </ul>
- *
- * @since 9.2.0
- */
-public class PathRemainderAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private PathRemainderAnnotation() {}
-
- private static final AnnotationProvider AP = AnnotationProvider.INSTANCE;
-
- /**
- * Applies targeted {@link PathRemainder} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<PathRemainder,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(PathRemainder.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<PathRemainder> ai, BeanContext.Builder b) {
- PathRemainder a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link PathRemainder @PathRemainder annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- PathRemainder[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTMF {
-
- private Class<? extends HttpPartParser> parser = HttpPartParser.Void.class;
- private String[] description = {};
- private Class<? extends HttpPartSerializer> serializer = HttpPartSerializer.Void.class;
- private Schema schema = SchemaAnnotation.DEFAULT;
- private String def = "";
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(PathRemainder.class);
- }
-
- /**
- * Instantiates a new {@link PathRemainder @PathRemainder} object initialized with this builder.
- *
- * @return A new {@link PathRemainder @PathRemainder} object.
- */
- public PathRemainder build() {
- return new Object(this);
- }
-
- /**
- * Sets the {@link PathRemainder#def} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder def(String value) {
- def = value;
- return this;
- }
-
- /**
- * Sets the {@link PathRemainder#description} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link PathRemainder#parser} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder parser(Class<? extends HttpPartParser> value) {
- parser = value;
- return this;
- }
-
- /**
- * Sets the {@link PathRemainder#schema} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder schema(Schema value) {
- schema = value;
- return this;
- }
-
- /**
- * Sets the {@link PathRemainder#serializer} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder serializer(Class<? extends HttpPartSerializer> value) {
- serializer = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderMF */
- public Builder on(Field...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(FieldInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements PathRemainder {
-
- private final String[] description;
- private final Class<? extends HttpPartParser> parser;
- private final Class<? extends HttpPartSerializer> serializer;
- private final String def;
- private final Schema schema;
-
- Object(PathRemainderAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- def = b.def;
- parser = b.parser;
- schema = b.schema;
- serializer = b.serializer;
- }
-
- @Override /* Overridden from PathRemainder */
- public String def() {
- return def;
- }
-
- @Override /* Overridden from PathRemainder */
- public Class<? extends HttpPartParser> parser() {
- return parser;
- }
-
- @Override /* Overridden from PathRemainder */
- public Schema schema() {
- return schema;
- }
-
- @Override /* Overridden from PathRemainder */
- public Class<? extends HttpPartSerializer> serializer() {
- return serializer;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final PathRemainder DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-
- /**
- * Returns <jk>true</jk> if the specified annotation contains all default values.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if the specified annotation contains all default values.
- */
- public static boolean empty(PathRemainder a) {
- return a == null || DEFAULT.equals(a);
- }
-
- /**
- * Finds the default value from the specified list of annotations.
- *
- * @param pi The parameter.
- * @return The last matching default value, or empty if not found.
- */
- public static Optional<String> findDef(ParameterInfo pi) {
- // @formatter:off
- return AP.find(PathRemainder.class, pi)
- .stream()
- .map(AnnotationInfo::inner)
- .filter(x -> ne(x.def()))
- .findFirst()
- .map(x -> x.def());
- // @formatter:on
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
deleted file mode 100644
index 276e74b564..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-import static org.apache.juneau.commons.utils.StringUtils.*;
-import static org.apache.juneau.commons.utils.Utils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link Query @Query} annotation.
- *
- */
-public class QueryAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private QueryAnnotation() {}
-
- private static final AnnotationProvider AP = AnnotationProvider.INSTANCE;
-
- /**
- * Applies targeted {@link Query} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<Query,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(Query.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<Query> ai, BeanContext.Builder b) {
- var a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link Query @Query annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- Query[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTMF {
-
- private String[] description = {};
- private Class<? extends HttpPartParser> parser = HttpPartParser.Void.class;
- private Class<? extends HttpPartSerializer> serializer = HttpPartSerializer.Void.class;
- private Schema schema = SchemaAnnotation.DEFAULT;
- private String name = "";
- private String value = "";
- private String def = "";
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(Query.class);
- }
-
- /**
- * Instantiates a new {@link Query @Query} object initialized with this builder.
- *
- * @return A new {@link Query @Query} object.
- */
- public Query build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link Query#def} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder def(String value) {
- def = value;
- return this;
- }
-
- /**
- * Sets the {@link Query#name} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder name(String value) {
- name = value;
- return this;
- }
-
- /**
- * Sets the {@link Query#parser} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder parser(Class<? extends HttpPartParser> value) {
- parser = value;
- return this;
- }
-
- /**
- * Sets the {@link Query#schema} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder schema(Schema value) {
- schema = value;
- return this;
- }
-
- /**
- * Sets the {@link Query#serializer} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder serializer(Class<? extends HttpPartSerializer> value) {
- serializer = value;
- return this;
- }
-
- /**
- * Sets the {@link Query#value} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder value(String value) {
- this.value = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderMF */
- public Builder on(Field...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(FieldInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTMF */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements Query {
-
- private final String[] description;
- private final Class<? extends HttpPartParser> parser;
- private final Class<? extends HttpPartSerializer> serializer;
- private final String name;
- private final String value;
- private final String def;
- private final Schema schema;
-
- Object(QueryAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- name = b.name;
- parser = b.parser;
- schema = b.schema;
- serializer = b.serializer;
- value = b.value;
- def = b.def;
- }
-
- @Override /* Overridden from Query */
- public String def() {
- return def;
- }
-
- @Override /* Overridden from Query */
- public String name() {
- return name;
- }
-
- @Override /* Overridden from Query */
- public Class<? extends HttpPartParser> parser() {
- return parser;
- }
-
- @Override /* Overridden from Query */
- public Schema schema() {
- return schema;
- }
-
- @Override /* Overridden from Query */
- public Class<? extends HttpPartSerializer> serializer() {
- return serializer;
- }
-
- @Override /* Overridden from Query */
- public String value() {
- return value;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final Query DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-
- /**
- * Returns <jk>true</jk> if the specified annotation contains all default values.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if the specified annotation contains all default values.
- */
- public static boolean empty(Query a) {
- return a == null || DEFAULT.equals(a);
- }
-
- /**
- * Finds the default value from the specified list of annotations.
- *
- * @param pi The parameter.
- * @return The last matching default value, or empty if not found.
- */
- public static Optional<String> findDef(ParameterInfo pi) {
- // @formatter:off
- return AP.find(Query.class, pi)
- .stream()
- .map(AnnotationInfo::inner)
- .filter(x -> ne(x.def()))
- .findFirst()
- .map(Query::def);
- // @formatter:on
- }
-
- /**
- * Finds the name from the specified list of annotations.
- *
- * @param pi The parameter.
- * @return The last matching name, or empty if not found.
- */
- public static Optional<String> findName(ParameterInfo pi) {
- // @formatter:off
- return AP.find(Query.class, pi)
- .stream()
- .map(AnnotationInfo::inner)
- .filter(x -> isAnyNotBlank(x.value(), x.name()))
- .findFirst()
- .map(x -> firstNonBlank(x.name(), x.value()));
- // @formatter:on
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/RequestAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/RequestAnnotation.java
deleted file mode 100644
index a056434a18..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/RequestAnnotation.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-
-import java.lang.annotation.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link Request @Request} annotation.
- *
- */
-public class RequestAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private RequestAnnotation() {}
-
- /**
- * Applies targeted {@link Request} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<Request,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(Request.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<Request> ai, BeanContext.Builder b) {
- Request a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link Request @Request annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- Request[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderT {
-
- private String[] description = {};
- private Class<? extends HttpPartParser> parser = HttpPartParser.Void.class;
- private Class<? extends HttpPartSerializer> serializer = HttpPartSerializer.Void.class;
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(Request.class);
- }
-
- /**
- * Instantiates a new {@link Request @Request} object initialized with this builder.
- *
- * @return A new {@link Request @Request} object.
- */
- public Request build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link Request#parser} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder parser(Class<? extends HttpPartParser> value) {
- parser = value;
- return this;
- }
-
- /**
- * Sets the {@link Request#serializer} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder serializer(Class<? extends HttpPartSerializer> value) {
- serializer = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements Request {
-
- private final String[] description;
- private final Class<? extends HttpPartParser> parser;
- private final Class<? extends HttpPartSerializer> serializer;
-
- Object(RequestAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- parser = b.parser;
- serializer = b.serializer;
- }
-
- @Override /* Overridden from Request */
- public Class<? extends HttpPartParser> parser() {
- return parser;
- }
-
- @Override /* Overridden from Request */
- public Class<? extends HttpPartSerializer> serializer() {
- return serializer;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final Request DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
deleted file mode 100644
index 956142363c..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link Response @Response} annotation.
- *
- */
-public class ResponseAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private ResponseAnnotation() {}
-
- /**
- * Applies targeted {@link Response} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<Response,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(Response.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<Response> ai, BeanContext.Builder b) {
- Response a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link Response @Response annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- Response[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTM {
-
- private String[] description = {};
- private Class<? extends HttpPartParser> parser = HttpPartParser.Void.class;
- private Class<? extends HttpPartSerializer> serializer = HttpPartSerializer.Void.class;
- private Header[] headers = {};
- private Schema schema = SchemaAnnotation.DEFAULT;
- private String[] examples = {};
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(Response.class);
- }
-
- /**
- * Instantiates a new {@link Response @Response} object initialized with this builder.
- *
- * @return A new {@link Response @Response} object.
- */
- public Response build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link Response#examples} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder examples(String...value) {
- examples = value;
- return this;
- }
-
- /**
- * Sets the {@link Response#headers} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder headers(Header...value) {
- headers = value;
- return this;
- }
-
- /**
- * Sets the {@link Response#parser} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder parser(Class<? extends HttpPartParser> value) {
- parser = value;
- return this;
- }
-
- /**
- * Sets the {@link Response#schema} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder schema(Schema value) {
- schema = value;
- return this;
- }
-
- /**
- * Sets the {@link Response#serializer} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder serializer(Class<? extends HttpPartSerializer> value) {
- serializer = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTM */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements Response {
-
- private final String[] description;
- private final Class<? extends HttpPartParser> parser;
- private final Class<? extends HttpPartSerializer> serializer;
- private final Header[] headers;
- private final Schema schema;
- private final String[] examples;
-
- Object(ResponseAnnotation.Builder b) {
- super(b);
- description = copyOf(b.description);
- examples = copyOf(b.examples);
- headers = copyOf(b.headers);
- parser = b.parser;
- schema = b.schema;
- serializer = b.serializer;
- }
-
- @Override /* Overridden from Response */
- public String[] examples() {
- return examples;
- }
-
- @Override /* Overridden from Response */
- public Header[] headers() {
- return headers;
- }
-
- @Override /* Overridden from Response */
- public Class<? extends HttpPartParser> parser() {
- return parser;
- }
-
- @Override /* Overridden from Response */
- public Schema schema() {
- return schema;
- }
-
- @Override /* Overridden from Response */
- public Class<? extends HttpPartSerializer> serializer() {
- return serializer;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final Response DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-
- /**
- * Returns <jk>true</jk> if the specified annotation contains all default values.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if the specified annotation contains all default values.
- */
- public static boolean empty(Response a) {
- return a == null || DEFAULT.equals(a);
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCodeAnnotation.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCodeAnnotation.java
deleted file mode 100644
index fb145315c5..0000000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCodeAnnotation.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.commons.utils.CollectionUtils.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.commons.annotation.*;
-import org.apache.juneau.commons.reflect.*;
-import org.apache.juneau.svl.*;
-
-/**
- * Utility classes and methods for the {@link StatusCode @StatusCode} annotation.
- *
- */
-public class StatusCodeAnnotation {
-
- /**
- * Prevents instantiation.
- */
- private StatusCodeAnnotation() {}
-
- /**
- * Applies targeted {@link StatusCode} annotations to a {@link org.apache.juneau.BeanContext.Builder}.
- */
- public static class Applier extends AnnotationApplier<StatusCode,BeanContext.Builder> {
-
- /**
- * Constructor.
- *
- * @param vr The resolver for resolving values in annotations.
- */
- public Applier(VarResolverSession vr) {
- super(StatusCode.class, BeanContext.Builder.class, vr);
- }
-
- @Override
- public void apply(AnnotationInfo<StatusCode> ai, BeanContext.Builder b) {
- StatusCode a = ai.inner();
- if (isEmptyArray(a.on()) && isEmptyArray(a.onClass()))
- return;
- b.annotations(a);
- }
- }
-
- /**
- * A collection of {@link StatusCode @StatusCode annotations}.
- */
- @Documented
- @Target({ METHOD, TYPE })
- @Retention(RUNTIME)
- @Inherited
- public static @interface Array {
-
- /**
- * The child annotations.
- *
- * @return The annotation value.
- */
- StatusCode[] value();
- }
-
- /**
- * Builder class.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='jm'>{@link org.apache.juneau.BeanContext.Builder#annotations(Annotation...)}
- * </ul>
- */
- public static class Builder extends AppliedAnnotationObject.BuilderTM {
-
- private String[] description = {};
- private int[] value = {};
-
- /**
- * Constructor.
- */
- protected Builder() {
- super(StatusCode.class);
- }
-
- /**
- * Instantiates a new {@link StatusCode @StatusCode} object initialized with this builder.
- *
- * @return A new {@link StatusCode @StatusCode} object.
- */
- public StatusCode build() {
- return new Object(this);
- }
-
- /**
- * Sets the description property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder description(String...value) {
- description = value;
- return this;
- }
-
- /**
- * Sets the {@link StatusCode#value} property on this annotation.
- *
- * @param value The new value for this property.
- * @return This object.
- */
- public Builder value(int...value) {
- this.value = value;
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.Builder */
- public Builder on(String...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(Class<?>...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedOnClassAnnotationObject.Builder */
- public Builder onClass(Class<?>...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderM */
- public Builder on(Method...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder on(ClassInfo...value) {
- super.on(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderT */
- public Builder onClass(ClassInfo...value) {
- super.onClass(value);
- return this;
- }
-
- @Override /* Overridden from AppliedAnnotationObject.BuilderTM */
- public Builder on(MethodInfo...value) {
- super.on(value);
- return this;
- }
-
- }
-
- @SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
- })
- private static class Object extends AppliedOnClassAnnotationObject implements StatusCode {
-
- private final String[] description;
- private final int[] value;
-
- Object(StatusCodeAnnotation.Builder b) {
- super(b);
- this.description = copyOf(b.description);
- this.value = Arrays.copyOf(b.value, b.value.length);
- }
-
- @Override /* Overridden from Response */
- public int[] value() {
- return value;
- }
-
- @Override /* Overridden from annotation */
- public String[] description() {
- return description;
- }
- }
-
- /** Default value */
- public static final StatusCode DEFAULT = create().build();
-
- /**
- * Instantiates a new builder for this class.
- *
- * @return A new builder object.
- */
- public static Builder create() {
- return new Builder();
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(Class<?>...on) {
- return create().on(on);
- }
-
- /**
- * Instantiates a new builder for this class.
- *
- * @param on The targets this annotation applies to.
- * @return A new builder object.
- */
- public static Builder create(String...on) {
- return create().on(on);
- }
-}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartMarshalling.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartMarshalling.java
new file mode 100644
index 0000000000..4e4688d328
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartMarshalling.java
@@ -0,0 +1,64 @@
+/*
+ * 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.httppart;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+import java.lang.annotation.*;
+
+/**
+ * Specifies the {@link HttpPartSerializer} and {@link HttpPartParser} to use for serializing/parsing HTTP parts.
+ *
+ * <p>
+ * Can be applied alongside parameter annotations such as <ja>@Query</ja>, <ja>@Header</ja>, <ja>@FormData</ja>,
+ * <ja>@Path</ja>, <ja>@Request</ja>, and <ja>@Response</ja> to override the default part serializer/parser
+ * for that specific parameter.
+ *
+ * <p>
+ * This annotation is used by the classic {@code RestClient} remote-proxy path.
+ * The next-generation {@code NgRestClient} does not use this annotation.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bjava'>
+ * <ja>@RemoteGet</ja>(<js>"/mymethod"</js>)
+ * String myMethod(<ja>@Query</ja>(<js>"foo"</js>) <ja>@HttpPartMarshalling</ja>(serializer=MySerializer.<jk>class</jk>) String <jv>foo</jv>);
+ * </p>
+ *
+ * <h5 class='section'>See Also:</h5><ul>
+ * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/HttpPartSerializersParsers">HTTP Part Serializers and Parsers</a>
+ * </ul>
+ */
+@Documented
+@Target({ PARAMETER, METHOD, TYPE, FIELD })
+@Retention(RUNTIME)
+public @interface HttpPartMarshalling {
+
+ /**
+ * Specifies the {@link HttpPartParser} class used for parsing strings to values.
+ *
+ * @return The annotation value.
+ */
+ Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
+
+ /**
+ * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
+ *
+ * @return The annotation value.
+ */
+ Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index cd1a040492..c97b354664 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -42,7 +42,6 @@ import org.apache.juneau.commons.collections.*;
import org.apache.juneau.commons.lang.*;
import org.apache.juneau.commons.reflect.*;
import org.apache.juneau.commons.utils.*;
-import org.apache.juneau.http.annotation.*;
import org.apache.juneau.parser.*;
/**
@@ -449,33 +448,19 @@ public class HttpPartSchema {
* @return This object.
*/
public Builder apply(Annotation a) {
- if (a instanceof Content a2)
- apply(a2);
- else if (a instanceof Header a2)
- apply(a2);
- else if (a instanceof FormData a2)
- apply(a2);
- else if (a instanceof Query a2)
- apply(a2);
- else if (a instanceof Path a2)
- apply(a2);
- else if (a instanceof PathRemainder a2)
- apply(a2);
- else if (a instanceof Response a2)
- apply(a2);
- else if (a instanceof StatusCode a2)
- apply(a2);
- else if (a instanceof HasQuery a2)
- apply(a2);
- else if (a instanceof HasFormData a2)
- apply(a2);
- else if (a instanceof Schema a2)
- apply(a2);
- else if (cn(a.annotationType()).startsWith("jakarta.validation.constraints."))
+ if (a instanceof Schema a2)
+ return apply(a2);
+ if (a instanceof Items a2)
+ return apply(a2);
+ if (a instanceof SubItems a2)
+ return apply(a2);
+ if (a instanceof HttpPartMarshalling a2)
+ return apply(a2);
+ if (cn(a.annotationType()).startsWith("jakarta.validation.constraints.")) {
applyJakartaValidation(a);
- else
- throw rex("Builder.apply(@{0}) not defined", cn(a));
- return this;
+ return this;
+ }
+ return applyHttpAnnotation(a);
}
/**
@@ -2659,41 +2644,80 @@ public class HttpPartSchema {
return this;
}
- Builder apply(Content a) {
- if (! SchemaAnnotation.empty(a.schema()))
- apply(a.schema());
- default_(a.def());
- return this;
- }
-
- Builder apply(FormData a) {
- if (! SchemaAnnotation.empty(a.schema()))
- apply(a.schema());
- name(firstNonEmpty(a.name(), a.value()));
- default_(a.def());
+ Builder apply(HttpPartMarshalling a) {
parser(a.parser());
serializer(a.serializer());
return this;
}
- Builder apply(HasFormData a) {
- name(firstNonEmpty(a.name(), a.value()));
+ private Builder applyHttpAnnotation(Annotation a) {
+ var annotationName = a.annotationType().getSimpleName();
+
+ var schema = getAnnotationValue(a, "schema", Schema.class);
+ if (schema != null && ("Response".equals(annotationName) || !SchemaAnnotation.empty(schema)))
+ apply(schema);
+
+ var aName = getAnnotationString(a, "name");
+ var aValue = getAnnotationString(a, ANN_value);
+
+ switch (annotationName) {
+ case "PathRemainder" -> {
+ name("/*");
+ default_(getAnnotationString(a, "def"));
+ allowEmptyValue();
+ required(false);
+ }
+ case "Path" -> {
+ name(firstNonEmpty(aName, aValue));
+ var def = getAnnotationString(a, "def");
+ if (def != null && neq(NONE, def))
+ default_ = def;
+ if (startsWith(name, '/')) {
+ allowEmptyValue();
+ required(false);
+ } else if (required == null) {
+ required(def == null || eq(NONE, def));
+ }
+ }
+ case "Response" -> {
+ allowEmptyValue(true);
+ required(false);
+ }
+ case "StatusCode" -> codes(getAnnotationIntArray(a, ANN_value));
+ default -> {
+ name(firstNonEmpty(aName, aValue));
+ default_(getAnnotationString(a, "def"));
+ }
+ }
return this;
}
- Builder apply(HasQuery a) {
- name(firstNonEmpty(a.name(), a.value()));
- return this;
+ private static String getAnnotationString(Annotation a, String methodName) {
+ try {
+ var m = a.annotationType().getMethod(methodName);
+ if (m.getReturnType() == String.class)
+ return (String) m.invoke(a);
+ } catch (@SuppressWarnings("unused") NoSuchMethodException e) {
+ // Attribute doesn't exist on this annotation -- ignore
+ } catch (Exception e) {
+ throw rex(e);
+ }
+ return null;
}
- Builder apply(Header a) {
- if (! SchemaAnnotation.empty(a.schema()))
- apply(a.schema());
- name(firstNonEmpty(a.name(), a.value()));
- default_(a.def());
- parser(a.parser());
- serializer(a.serializer());
- return this;
+ private static int[] getAnnotationIntArray(Annotation a, String methodName) {
+ try {
+ var m = a.annotationType().getMethod(methodName);
+ if (m.getReturnType() == int[].class) {
+ var arr = (int[]) m.invoke(a);
+ return arr == null ? new int[0] : arr;
+ }
+ } catch (@SuppressWarnings("unused") NoSuchMethodException e) {
+ // Attribute doesn't exist on this annotation -- ignore
+ } catch (Exception e) {
+ throw rex(e);
+ }
+ return new int[0];
}
Builder apply(Items a) {
@@ -2753,63 +2777,6 @@ public class HttpPartSchema {
return this;
}
- Builder apply(Path a) {
- if (! SchemaAnnotation.empty(a.schema()))
- apply(a.schema());
- name(firstNonEmpty(a.name(), a.value()));
- String def = a.def();
- if (neq(NONE, def))
- default_ = def; // Set directly to allow empty strings as valid defaults
- parser(a.parser());
- serializer(a.serializer());
-
- // Path remainder always allows empty value.
- if (startsWith(name, '/')) {
- allowEmptyValue();
- required(false);
- } else if (required == null) {
- // Path parameters with default values are not required
- required(eq(NONE, def));
- }
-
- return this;
- }
-
- Builder apply(PathRemainder a) {
- if (! SchemaAnnotation.empty(a.schema()))
- apply(a.schema());
- // PathRemainder is always "/*"
- name("/*");
- default_(a.def());
- parser(a.parser());
- serializer(a.serializer());
-
- // Path remainder always allows empty value.
- allowEmptyValue();
- required(false);
-
- return this;
- }
-
- Builder apply(Query a) {
- if (! SchemaAnnotation.empty(a.schema()))
- apply(a.schema());
- name(firstNonEmpty(a.name(), a.value()));
- default_(a.def());
- parser(a.parser());
- serializer(a.serializer());
- return this;
- }
-
- Builder apply(Response a) {
- allowEmptyValue(true);
- apply(a.schema());
- parser(a.parser());
- required(false);
- serializer(a.serializer());
- return this;
- }
-
// -----------------------------------------------------------------------------------------------------------------
// Other
// -----------------------------------------------------------------------------------------------------------------
@@ -2866,11 +2833,6 @@ public class HttpPartSchema {
return this;
}
- Builder apply(StatusCode a) {
- codes(a.value());
- return this;
- }
-
Builder apply(SubItems a) {
default_(joinnlOrNull(a.default_(), a.df()));
enum_(toSet(a.enum_(), a.e()));
@@ -2892,15 +2854,15 @@ public class HttpPartSchema {
return this;
}
- Builder applyAll(Class<? extends Annotation> c, java.lang.reflect.Type t) {
+ public Builder applyAll(Class<? extends Annotation> c, java.lang.reflect.Type t) {
return apply(Schema.class, t).apply(c, t);
}
- Builder applyAll(Class<? extends Annotation> c, Method m) {
+ public Builder applyAll(Class<? extends Annotation> c, Method m) {
return apply(Schema.class, m).apply(c, m);
}
- Builder applyAll(Class<? extends Annotation> c, ParameterInfo mpi) {
+ public Builder applyAll(Class<? extends Annotation> c, ParameterInfo mpi) {
return apply(Schema.class, mpi).apply(c, mpi);
}
@@ -2935,7 +2897,8 @@ public class HttpPartSchema {
* @since 9.2.0
*/
@SuppressWarnings({
- "java:S3776" // Cognitive complexity acceptable for Jakarta validation application
+ "java:S3776", // Cognitive complexity acceptable for Jakarta validation application
+ "java:S6541" // Brain method: consolidated Jakarta validation constraint dispatch
})
Builder applyJakartaValidation(Annotation a) {
String simpleName = cns(a.annotationType());
@@ -3177,14 +3140,14 @@ public class HttpPartSchema {
* The annotation to look for.
* <br>Valid values:
* <ul>
- * <li>{@link Content}
- * <li>{@link Header}
- * <li>{@link Query}
- * <li>{@link FormData}
- * <li>{@link Path}
- * <li>{@link Response}
- * <li>{@link HasQuery}
- * <li>{@link HasFormData}
+ * <li><ja>@Content</ja>
+ * <li><ja>@Header</ja>
+ * <li><ja>@Query</ja>
+ * <li><ja>@FormData</ja>
+ * <li><ja>@Path</ja>
+ * <li><ja>@Response</ja>
+ * <li><ja>@HasQuery</ja>
+ * <li><ja>@HasFormData</ja>
* </ul>
* @param t
* The class containing the parameter.
@@ -3209,14 +3172,14 @@ public class HttpPartSchema {
* The annotation to look for.
* <br>Valid values:
* <ul>
- * <li>{@link Content}
- * <li>{@link Header}
- * <li>{@link Query}
- * <li>{@link FormData}
- * <li>{@link Path}
- * <li>{@link Response}
- * <li>{@link HasQuery}
- * <li>{@link HasFormData}
+ * <li><ja>@Content</ja>
+ * <li><ja>@Header</ja>
+ * <li><ja>@Query</ja>
+ * <li><ja>@FormData</ja>
+ * <li><ja>@Path</ja>
+ * <li><ja>@Response</ja>
+ * <li><ja>@HasQuery</ja>
+ * <li><ja>@HasFormData</ja>
* </ul>
* @param m
* The Java method with the return type being checked.
@@ -3241,14 +3204,14 @@ public class HttpPartSchema {
* The annotation to look for.
* <br>Valid values:
* <ul>
- * <li>{@link Content}
- * <li>{@link Header}
- * <li>{@link Query}
- * <li>{@link FormData}
- * <li>{@link Path}
- * <li>{@link Response}
- * <li>{@link HasQuery}
- * <li>{@link HasFormData}
+ * <li><ja>@Content</ja>
+ * <li><ja>@Header</ja>
+ * <li><ja>@Query</ja>
+ * <li><ja>@FormData</ja>
+ * <li><ja>@Path</ja>
+ * <li><ja>@Response</ja>
+ * <li><ja>@HasQuery</ja>
+ * <li><ja>@HasFormData</ja>
* </ul>
* @param mpi The Java method parameter.
* @return The schema information about the parameter.
@@ -4328,7 +4291,8 @@ public class HttpPartSchema {
* @throws SchemaValidationException if the specified parsed output does not validate against this schema.
*/
@SuppressWarnings({
- "java:S3776" // Cognitive complexity acceptable for output validation
+ "java:S3776", // Cognitive complexity acceptable for output validation
+ "java:S6541" // Brain method: schema output validation branches by OpenAPI part type
})
public <T> T validateOutput(T o, BeanContext bc) throws SchemaValidationException {
if (o == null) {
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java
index 8701506e4f..31f959dfb0 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSerializer.java
@@ -18,7 +18,6 @@ package org.apache.juneau.httppart;
import org.apache.juneau.*;
import org.apache.juneau.cp.*;
-import org.apache.juneau.http.annotation.*;
/**
* Interface used to convert POJOs to simple strings in HTTP headers, query parameters, form-data parameters, and URI
@@ -35,12 +34,7 @@ import org.apache.juneau.http.annotation.*;
* <p>
* This class is used in the following locations:
* <ul class='javatree'>
- * <li class='ja'>{@link FormData#serializer()}
- * <li class='ja'>{@link Query#serializer()}
- * <li class='ja'>{@link Header#serializer()}
- * <li class='ja'>{@link Path#serializer()}
- * <li class='ja'>{@link Request#serializer()}
- * <li class='ja'>{@link Response#serializer()}
+ * <li class='ja'>{@link HttpPartMarshalling#serializer()}
* <li class='jc'><c>RestClient.Builder.partSerializer(Class)</c>
* </ul>
*
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/ng/rest/client/remote/NgRemoteClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/ng/rest/client/remote/NgRemoteClient.java
index 7e6a8c2503..c7a5db2f5a 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/ng/rest/client/remote/NgRemoteClient.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/ng/rest/client/remote/NgRemoteClient.java
@@ -17,17 +17,15 @@
package org.apache.juneau.ng.rest.client.remote;
import static org.apache.juneau.commons.utils.AssertionUtils.assertArgNotNull;
+import static org.apache.juneau.commons.utils.StringUtils.firstNonEmpty;
import java.io.*;
import java.lang.reflect.*;
+import org.apache.juneau.http.annotation.Content;
import org.apache.juneau.http.remote.Remote;
import org.apache.juneau.http.remote.RemoteReturn;
import org.apache.juneau.ng.http.HttpBody;
-import org.apache.juneau.ng.http.remote.Body;
-import org.apache.juneau.ng.http.remote.Header;
-import org.apache.juneau.ng.http.remote.Path;
-import org.apache.juneau.ng.http.remote.Query;
import org.apache.juneau.ng.http.remote.RrpcInterfaceMeta;
import org.apache.juneau.ng.rest.client.*;
@@ -44,7 +42,7 @@ import org.apache.juneau.ng.rest.client.*;
* <ja>@Remote</ja>(path=<js>"/api/users"</js>)
* <jk>public interface</jk> UserService {{
* <ja>@RemoteGet</ja>(<js>"/{id}"</js>)
- * String getUser(<ja>@Path</ja>(<js>"id"</js>) String id);
+ * String getUser(<ja>@Path</ja>(<js>"id"</js>) String <jv>id</jv>);
* }}
*
* UserService <jv>svc</jv> = client.remote(UserService.<jk>class</jk>);
@@ -150,7 +148,6 @@ public final class NgRemoteClient {
default -> throw new IllegalArgumentException("Unsupported HTTP method: " + httpMethod); // HTT
};
- // Process method parameters
if (args != null) {
var params = method.getParameters();
for (int i = 0; i < params.length; i++) {
@@ -159,33 +156,29 @@ public final class NgRemoteClient {
if (arg == null)
continue;
- // Check for @Path annotation on parameter
- var pathAnnotation = param.getAnnotation(Path.class);
+ var pathAnnotation = param.getAnnotation(org.apache.juneau.http.annotation.Path.class);
if (pathAnnotation != null) {
- var name = pathAnnotation.value().isEmpty() ? param.getName() : pathAnnotation.value();
+ var name = firstNonEmpty(pathAnnotation.value(), pathAnnotation.name(), param.getName());
req = req.pathData(name, String.valueOf(arg));
continue;
}
- // Check for @Query annotation on parameter
- var queryAnnotation = param.getAnnotation(Query.class);
+ var queryAnnotation = param.getAnnotation(org.apache.juneau.http.annotation.Query.class);
if (queryAnnotation != null) {
- var name = queryAnnotation.value().isEmpty() ? param.getName() : queryAnnotation.value();
+ var name = firstNonEmpty(queryAnnotation.value(), queryAnnotation.name(), param.getName());
req = req.queryData(name, String.valueOf(arg));
continue;
}
- // Check for @Header annotation on parameter
- var headerAnnotation = param.getAnnotation(Header.class);
+ var headerAnnotation = param.getAnnotation(org.apache.juneau.http.annotation.Header.class);
if (headerAnnotation != null) {
- var name = headerAnnotation.value().isEmpty() ? param.getName() : headerAnnotation.value();
+ var name = firstNonEmpty(headerAnnotation.value(), headerAnnotation.name(), param.getName());
req = req.header(name, String.valueOf(arg));
continue;
}
- // Check for @Body annotation on parameter
- var bodyAnnotation = param.getAnnotation(Body.class);
- if (bodyAnnotation != null) {
+ var contentAnnotation = param.getAnnotation(Content.class);
+ if (contentAnnotation != null) {
if (arg instanceof HttpBody b)
req = req.body(b);
else
@@ -193,7 +186,6 @@ public final class NgRemoteClient {
continue;
}
- // Single unannotated parameter — treat as body if it's the only one
if (params.length == 1) {
if (arg instanceof HttpBody b)
req = req.body(b);
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/CollectionFormatType.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/CollectionFormatType.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/CollectionFormatType.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/CollectionFormatType.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Contact.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Contact.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Contact.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Contact.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ContactAnnotation.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ContactAnnotation.java
similarity index 88%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ContactAnnotation.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ContactAnnotation.java
index 358637b3d5..aa60ff0cc1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ContactAnnotation.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ContactAnnotation.java
@@ -60,7 +60,7 @@ public class ContactAnnotation {
* @return A new {@link Contact @Contact} object.
*/
public Contact build() {
- return new Object(this);
+ return new Instance(this);
}
/**
@@ -109,16 +109,18 @@ public class ContactAnnotation {
}
@SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "java:S2160", // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "ClassExplicitlyAnnotation", // IntelliJ / SonarLint: Instance implements @Contact (AnnotationObject runtime proxy pattern)
+ "all" // Eclipse JDT: AnnotationTypeUsedAsSuperInterface has no dedicated @SuppressWarnings token (JLS 9.6)
})
- private static class Object extends AnnotationObject implements Contact {
+ private static class Instance extends AnnotationObject implements Contact {
private final String[] description;
private final String email;
private final String name;
private final String url;
- Object(ContactAnnotation.Builder b) {
+ Instance(ContactAnnotation.Builder b) {
super(b);
description = copyOf(b.description);
email = b.email;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Content.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Content.java
similarity index 85%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Content.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Content.java
index 65e904f671..a0e7fd2123 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Content.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Content.java
@@ -21,8 +21,9 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.json.*;
+import org.apache.juneau.annotation.Schema;
+
+import org.apache.juneau.json.JsonSchemaSerializer;
/**
* REST request body annotation.
@@ -103,8 +104,6 @@ import org.apache.juneau.json.*;
@Target({ PARAMETER, METHOD, TYPE })
@Retention(RUNTIME)
@Inherited
-@Repeatable(ContentAnnotation.Array.class)
-@ContextApply(ContentAnnotation.Applier.class)
public @interface Content {
/**
@@ -128,31 +127,6 @@ public @interface Content {
*/
String[] description() default {};
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
/**
* <mk>schema</mk> field of the <a class='doclink' href='https://swagger.io/specification/v2#parameterObject'>Swagger Parameter Object</a>.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/FormData.java
similarity index 84%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/FormData.java
index 2d49077cb3..3602ec3094 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/FormData.java
@@ -21,9 +21,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.oapi.*;
+import org.apache.juneau.annotation.Schema;
/**
* REST request form-data annotation.
@@ -119,8 +117,6 @@ import org.apache.juneau.oapi.*;
@Target({ PARAMETER, METHOD, TYPE, FIELD })
@Retention(RUNTIME)
@Inherited
-@Repeatable(FormDataAnnotation.Array.class)
-@ContextApply(FormDataAnnotation.Applier.class)
public @interface FormData {
/**
@@ -204,41 +200,6 @@ public @interface FormData {
*/
String name() default "";
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
-
/**
* <mk>schema</mk> field of the <a class='doclink' href='https://swagger.io/specification/v2#parameterObject'>Swagger Parameter Object</a>.
*
@@ -264,16 +225,6 @@ public @interface FormData {
*/
Schema schema() default @Schema;
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
-
/**
* A synonym for {@link #name()}.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormatType.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/FormatType.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormatType.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/FormatType.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormData.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/HasFormData.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasFormData.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/HasFormData.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQuery.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/HasQuery.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQuery.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/HasQuery.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Header.java
similarity index 80%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Header.java
index e713d5b49c..0b1a7bbf83 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Header.java
@@ -21,9 +21,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.oapi.*;
+import org.apache.juneau.annotation.Schema;
/**
* REST request header annotation.
@@ -85,8 +83,6 @@ import org.apache.juneau.oapi.*;
@Target({ PARAMETER, METHOD, TYPE, FIELD })
@Retention(RUNTIME)
@Inherited
-@Repeatable(HeaderAnnotation.Array.class)
-@ContextApply(HeaderAnnotation.Applier.class)
public @interface Header {
/**
@@ -165,41 +161,6 @@ public @interface Header {
*/
String name() default "";
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
-
/**
* <mk>schema</mk> field of the <a class='doclink' href='https://swagger.io/specification/v2#parameterObject'>Swagger Parameter Object</a>.
*
@@ -225,16 +186,6 @@ public @interface Header {
*/
Schema schema() default @Schema;
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
-
/**
* A synonym for {@link #name()}.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/License.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/License.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/License.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/License.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/LicenseAnnotation.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/LicenseAnnotation.java
similarity index 86%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/LicenseAnnotation.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/LicenseAnnotation.java
index f3c9226241..738a54e6aa 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/LicenseAnnotation.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/LicenseAnnotation.java
@@ -59,7 +59,7 @@ public class LicenseAnnotation {
* @return A new {@link License @License} object.
*/
public License build() {
- return new Object(this);
+ return new Instance(this);
}
/**
@@ -98,15 +98,17 @@ public class LicenseAnnotation {
}
@SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "java:S2160", // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "ClassExplicitlyAnnotation", // IntelliJ / SonarLint: Instance implements @License (AnnotationObject runtime proxy pattern)
+ "all" // Eclipse JDT: AnnotationTypeUsedAsSuperInterface has no dedicated @SuppressWarnings token (JLS 9.6)
})
- private static class Object extends AnnotationObject implements License {
+ private static class Instance extends AnnotationObject implements License {
private final String[] description;
private final String name;
private final String url;
- Object(LicenseAnnotation.Builder b) {
+ Instance(LicenseAnnotation.Builder b) {
super(b);
description = copyOf(b.description);
name = b.name;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ParameterType.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ParameterType.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ParameterType.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ParameterType.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Path.java
similarity index 81%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Path.java
index 1a84a3ad6f..73fc6b54b3 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Path.java
@@ -22,9 +22,7 @@ import static org.apache.juneau.Constants.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.oapi.*;
+import org.apache.juneau.annotation.Schema;
/**
* REST request path annotation.
@@ -83,8 +81,6 @@ import org.apache.juneau.oapi.*;
@Target({ PARAMETER, METHOD, TYPE, FIELD })
@Retention(RUNTIME)
@Inherited
-@Repeatable(PathAnnotation.Array.class)
-@ContextApply(PathAnnotation.Applier.class)
public @interface Path {
/**
@@ -171,41 +167,6 @@ public @interface Path {
*/
String name() default "";
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
-
/**
* <mk>schema</mk> field of the <a class='doclink' href='https://swagger.io/specification/v2#parameterObject'>Swagger Parameter Object</a>.
*
@@ -231,16 +192,6 @@ public @interface Path {
*/
Schema schema() default @Schema;
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
-
/**
* A synonym for {@link #name()}.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainder.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/PathRemainder.java
similarity index 72%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainder.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/PathRemainder.java
index f5c58ce251..98342f5004 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathRemainder.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/PathRemainder.java
@@ -21,9 +21,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.oapi.*;
+import org.apache.juneau.annotation.Schema;
/**
* REST request path remainder annotation.
@@ -87,8 +85,6 @@ import org.apache.juneau.oapi.*;
@Target({ PARAMETER, METHOD, TYPE, FIELD })
@Retention(RUNTIME)
@Inherited
-@Repeatable(PathRemainderAnnotation.Array.class)
-@ContextApply(PathRemainderAnnotation.Applier.class)
public @interface PathRemainder {
/**
@@ -105,41 +101,6 @@ public @interface PathRemainder {
*/
String[] description() default {};
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
-
/**
* <mk>schema</mk> field of the <a class='doclink' href='https://swagger.io/specification/v2#parameterObject'>Swagger Parameter Object</a>.
*
@@ -165,13 +126,4 @@ public @interface PathRemainder {
*/
Schema schema() default @Schema;
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Query.java
similarity index 81%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Query.java
index 0d2f0b32f5..ecc71e4f96 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Query.java
@@ -21,9 +21,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.oapi.*;
+import org.apache.juneau.annotation.Schema;
/**
* REST request form-data annotation.
@@ -93,8 +91,6 @@ import org.apache.juneau.oapi.*;
@Target({ PARAMETER, METHOD, TYPE, FIELD })
@Retention(RUNTIME)
@Inherited
-@Repeatable(QueryAnnotation.Array.class)
-@ContextApply(QueryAnnotation.Applier.class)
public @interface Query {
/**
@@ -176,41 +172,6 @@ public @interface Query {
*/
String name() default "";
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
-
/**
* <mk>schema</mk> field of the <a class='doclink' href='https://swagger.io/specification/v2#parameterObject'>Swagger Parameter Object</a>.
*
@@ -236,16 +197,6 @@ public @interface Query {
*/
Schema schema() default @Schema;
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
-
/**
* A synonym for {@link #name()}.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Request.java
similarity index 74%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Request.java
index 7d2697c3ac..13ecc0d2bc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Request.java
@@ -21,10 +21,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.oapi.*;
-
/**
* Request bean annotation.
*
@@ -144,8 +140,6 @@ import org.apache.juneau.oapi.*;
@Target({ PARAMETER, TYPE, METHOD })
@Retention(RUNTIME)
@Inherited
-@Repeatable(RequestAnnotation.Array.class)
-@ContextApply(RequestAnnotation.Applier.class)
public @interface Request {
/**
@@ -156,48 +150,4 @@ public @interface Request {
*/
String[] description() default {};
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
-
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Response.java
similarity index 74%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Response.java
index 40bb6dbae3..f5fe133cd2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Response.java
@@ -21,9 +21,7 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.httppart.*;
-import org.apache.juneau.oapi.*;
+import org.apache.juneau.annotation.Schema;
/**
* REST response annotation.
@@ -52,8 +50,6 @@ import org.apache.juneau.oapi.*;
@Target({ PARAMETER, TYPE, METHOD })
@Retention(RUNTIME)
@Inherited
-@Repeatable(ResponseAnnotation.Array.class)
-@ContextApply(ResponseAnnotation.Applier.class)
public @interface Response {
/**
@@ -117,41 +113,6 @@ public @interface Response {
*/
Header[] headers() default {};
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
- /**
- * Specifies the {@link HttpPartParser} class used for parsing strings to values.
- *
- * <p>
- * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
-
/**
* <mk>schema</mk> field of the <a class="doclink" href="https://swagger.io/specification/v2#responseObject">Swagger Response Object</a>.
*
@@ -167,13 +128,4 @@ public @interface Response {
*/
Schema schema() default @Schema;
- /**
- * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
- *
- * <p>
- * Overrides for this part the part serializer defined on the REST resource which by default is {@link OpenApiSerializer}.
- *
- * @return The annotation value.
- */
- Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
}
\ No newline at end of file
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
similarity index 50%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
index 5956386d5f..6ed6728968 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HasQueryAnnotation.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
@@ -20,18 +20,19 @@ import static org.apache.juneau.commons.utils.CollectionUtils.*;
import java.lang.annotation.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.commons.annotation.*;
/**
- * Utility classes and methods for the {@link HasQuery @HasQuery} annotation.
+ * Utility classes and methods for the {@link Response @Response} annotation.
*
*/
-public class HasQueryAnnotation {
+public class ResponseAnnotation {
/**
* Prevents instantiation.
*/
- private HasQueryAnnotation() {}
+ private ResponseAnnotation() {}
/**
* Builder class.
@@ -43,23 +44,24 @@ public class HasQueryAnnotation {
public static class Builder extends AnnotationObject.Builder {
private String[] description = {};
- private String name = "";
- private String value = "";
+ private Header[] headers = {};
+ private Schema schema = SchemaAnnotation.DEFAULT;
+ private String[] examples = {};
/**
* Constructor.
*/
protected Builder() {
- super(HasQuery.class);
+ super(Response.class);
}
/**
- * Instantiates a new {@link HasQuery @HasQuery} object initialized with this builder.
+ * Instantiates a new {@link Response @Response} object initialized with this builder.
*
- * @return A new {@link HasQuery @HasQuery} object.
+ * @return A new {@link Response @Response} object.
*/
- public HasQuery build() {
- return new Object(this);
+ public Response build() {
+ return new Instance(this);
}
/**
@@ -74,53 +76,73 @@ public class HasQueryAnnotation {
}
/**
- * Sets the {@link HasQuery#name} property on this annotation.
+ * Sets the {@link Response#examples} property on this annotation.
*
* @param value The new value for this property.
* @return This object.
*/
- public Builder name(String value) {
- name = value;
+ public Builder examples(String...value) {
+ examples = value;
return this;
}
/**
- * Sets the {@link HasQuery#value} property on this annotation.
+ * Sets the {@link Response#headers} property on this annotation.
*
* @param value The new value for this property.
* @return This object.
*/
- public Builder value(String value) {
- this.value = value;
+ public Builder headers(Header...value) {
+ headers = value;
+ return this;
+ }
+
+ /**
+ * Sets the {@link Response#schema} property on this annotation.
+ *
+ * @param value The new value for this property.
+ * @return This object.
+ */
+ public Builder schema(Schema value) {
+ schema = value;
return this;
}
}
@SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "java:S2160", // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "ClassExplicitlyAnnotation", // IntelliJ / SonarLint: Instance implements @Response (AnnotationObject runtime proxy pattern)
+ "all" // Eclipse JDT: AnnotationTypeUsedAsSuperInterface has no dedicated @SuppressWarnings token (JLS 9.6)
})
- private static class Object extends AnnotationObject implements HasQuery {
+ private static class Instance extends AnnotationObject implements Response {
private final String[] description;
- private final String name;
- private final String value;
+ private final Header[] headers;
+ private final Schema schema;
+ private final String[] examples;
- Object(HasQueryAnnotation.Builder b) {
+ Instance(ResponseAnnotation.Builder b) {
super(b);
description = copyOf(b.description);
- name = b.name;
- value = b.value;
+ examples = copyOf(b.examples);
+ headers = copyOf(b.headers);
+ schema = b.schema;
}
- @Override
- public String name() {
- return name;
+ @Override /* Overridden from Response */
+ public String[] examples() {
+ return examples;
}
- @Override
- public String value() {
- return value;
+ @Override /* Overridden from Response */
+ public Header[] headers() {
+ return headers;
+ }
+
+ @Override /* Overridden from Response */
+ public Schema schema() {
+ return schema;
}
@Override /* Overridden from annotation */
@@ -130,7 +152,7 @@ public class HasQueryAnnotation {
}
/** Default value */
- public static final HasQuery DEFAULT = create().build();
+ public static final Response DEFAULT = create().build();
/**
* Instantiates a new builder for this class.
@@ -140,4 +162,14 @@ public class HasQueryAnnotation {
public static Builder create() {
return new Builder();
}
-}
\ No newline at end of file
+
+ /**
+ * Returns <jk>true</jk> if the specified annotation contains all default values.
+ *
+ * @param a The annotation to check.
+ * @return <jk>true</jk> if the specified annotation contains all default values.
+ */
+ public static boolean empty(Response a) {
+ return a == null || DEFAULT.equals(a);
+ }
+}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCode.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/StatusCode.java
similarity index 79%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCode.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/StatusCode.java
index 34672d1659..2013be64d2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/StatusCode.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/StatusCode.java
@@ -21,7 +21,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.commons.lang.*;
/**
@@ -104,8 +103,6 @@ import org.apache.juneau.commons.lang.*;
@Target({ PARAMETER, METHOD, TYPE })
@Retention(RUNTIME)
@Inherited
-@Repeatable(StatusCodeAnnotation.Array.class)
-@ContextApply(StatusCodeAnnotation.Applier.class)
public @interface StatusCode {
/**
@@ -116,31 +113,6 @@ public @interface StatusCode {
*/
String[] description() default {};
- /**
- * Dynamically apply this annotation to the specified classes.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- 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.
- *
- * <h5 class='section'>See Also:</h5><ul>
- * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
- * </ul>
- *
- * @return The annotation value.
- */
- Class<?>[] onClass() default {};
-
/**
* The HTTP response codes.
*
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Tag.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Tag.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Tag.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/Tag.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/TagAnnotation.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/TagAnnotation.java
similarity index 86%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/TagAnnotation.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/TagAnnotation.java
index fd90811a2c..3b21f9b658 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/TagAnnotation.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/TagAnnotation.java
@@ -60,7 +60,7 @@ public class TagAnnotation {
* @return A new {@link Tag @Tag} object.
*/
public Tag build() {
- return new Object(this);
+ return new Instance(this);
}
/**
@@ -99,15 +99,17 @@ public class TagAnnotation {
}
@SuppressWarnings({
- "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "java:S2160", // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
+ "ClassExplicitlyAnnotation", // IntelliJ / SonarLint: Instance implements @Tag (AnnotationObject runtime proxy pattern)
+ "all" // Eclipse JDT: AnnotationTypeUsedAsSuperInterface has no dedicated @SuppressWarnings token (JLS 9.6)
})
- private static class Object extends AnnotationObject implements Tag {
+ private static class Instance extends AnnotationObject implements Tag {
private final String[] description;
private final ExternalDocs externalDocs;
private final String name;
- Object(TagAnnotation.Builder b) {
+ Instance(TagAnnotation.Builder b) {
super(b);
description = copyOf(b.description);
externalDocs = b.externalDocs;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Example.png b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Example.png
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Example.png
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Example.png
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Swagger.png b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Swagger.png
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Swagger.png
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/doc-files/Body_Swagger.png
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/package-info.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/package-info.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/package-info.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/annotation/package-info.java
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/remote/RemoteReturn.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/remote/RemoteReturn.java
index 928abaa91e..d31123740d 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/remote/RemoteReturn.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/remote/RemoteReturn.java
@@ -39,8 +39,10 @@ public enum RemoteReturn {
* Full response object (caller must close when applicable).
*
* <p>
- * For {@link org.apache.juneau.rest.client.RestClient} proxies, the return type is typically {@link org.apache.juneau.rest.client.RestResponse}.
- * For {@link org.apache.juneau.ng.rest.client.NgRestClient} proxies, the return type is typically {@link org.apache.juneau.ng.rest.client.NgRestResponse}.
+ * For <c>org.apache.juneau.rest.client.RestClient</c> proxies, the return type is typically
+ * <c>org.apache.juneau.rest.client.RestResponse</c>.
+ * For <c>org.apache.juneau.ng.rest.client.NgRestClient</c> proxies, the return type is typically
+ * <c>org.apache.juneau.ng.rest.client.NgRestResponse</c>.
* </p>
*/
RESPONSE,
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/MethodInfoUtils.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/MethodInfoUtils.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/MethodInfoUtils.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/MethodInfoUtils.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
similarity index 95%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
index 1488d712bf..b20515bbdc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/RequestBeanMeta.java
@@ -17,9 +17,7 @@
package org.apache.juneau.httppart.bean;
import static org.apache.juneau.commons.reflect.ReflectionUtils.*;
-import static org.apache.juneau.commons.utils.ClassUtils.*;
import static org.apache.juneau.commons.utils.CollectionUtils.*;
-import static org.apache.juneau.commons.utils.Utils.*;
import static org.apache.juneau.httppart.HttpPartType.*;
import static org.apache.juneau.httppart.bean.MethodInfoUtils.*;
@@ -88,13 +86,8 @@ public class RequestBeanMeta {
return apply(mpi.getParameterType().inner()).apply(AP.find(Request.class, mpi).stream().findFirst().map(AnnotationInfo::inner).orElse(null));
}
- Builder apply(Request a) {
- if (nn(a)) {
- if (isNotVoid(a.serializer()))
- serializer.type(a.serializer());
- if (isNotVoid(a.parser()))
- parser.type(a.parser());
- }
+ Builder apply(@SuppressWarnings("unused") Request a) {
+ // Serializer/parser now specified via @HttpPartMarshalling annotation instead of @Request attributes
return this;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/RequestBeanPropertyMeta.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
similarity index 98%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
index ea9db10e70..350d464866 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
@@ -63,10 +63,7 @@ public class ResponseBeanMeta {
Builder apply(Response a) {
if (nn(a)) {
- if (isNotVoid(a.serializer()))
- partSerializer = a.serializer();
- if (isNotVoid(a.parser()))
- partParser = a.parser();
+ // Serializer/parser now specified via @HttpPartMarshalling annotation instead of @Response attributes
schema.apply(a.schema());
}
return this;
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanPropertyMeta.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanPropertyMeta.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanPropertyMeta.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanPropertyMeta.java
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/package-info.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/package-info.java
similarity index 100%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/package-info.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/httppart/bean/package-info.java
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Body.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Body.java
deleted file mode 100644
index 8ebc9446ff..0000000000
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Body.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.ng.http.remote;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-import org.apache.juneau.ng.http.HttpBody;
-
-/**
- * Marks a remote proxy method parameter as the HTTP request body.
- *
- * <p>
- * The parameter value is serialized as the request body. If the value is an
- * {@link HttpBody}, it is used directly; otherwise,
- * it is converted via {@code String.valueOf()} with content type {@code text/plain}.
- *
- * <p class='bjava'>
- * <ja>@Remote</ja>(path=<js>"/api/users"</js>)
- * <jk>public interface</jk> UserService {
- * <ja>@RemotePost</ja>
- * String createUser(<ja>@Body</ja> String json);
- *
- * <ja>@RemotePut</ja>(<js>"/{id}"</js>)
- * void updateUser(<ja>@Path</ja>(<js>"id"</js>) String id, <ja>@Body</ja> HttpBody body);
- * }
- * </p>
- *
- * <p>
- * <b>Beta — API subject to change:</b> This type is part of the next-generation REST client and HTTP stack
- * ({@code org.apache.juneau.ng.*}).
- *
- * @since 9.2.1
- */
-@Documented
-@Target(PARAMETER)
-@Retention(RUNTIME)
-public @interface Body {
-}
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Header.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Header.java
deleted file mode 100644
index 1a1c6a8d22..0000000000
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Header.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.ng.http.remote;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-/**
- * Binds a remote proxy method parameter to a request header.
- *
- * <p class='bjava'>
- * <ja>@Remote</ja>(path=<js>"/api/items"</js>)
- * <jk>public interface</jk> ItemService {
- * <ja>@RemoteGet</ja>
- * String getItems(<ja>@Header</ja>(<js>"Authorization"</js>) String token);
- * }
- * </p>
- *
- * <p>
- * <b>Beta — API subject to change:</b> This type is part of the next-generation REST client and HTTP stack
- * ({@code org.apache.juneau.ng.*}).
- *
- * @since 9.2.1
- */
-@Documented
-@Target(PARAMETER)
-@Retention(RUNTIME)
-public @interface Header {
-
- /**
- * The header name.
- *
- * @return The header name. If empty, the parameter name is used (requires {@code -parameters} compiler flag).
- */
- String value() default "";
-}
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Path.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Path.java
deleted file mode 100644
index fae58f70ad..0000000000
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Path.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.ng.http.remote;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-/**
- * Binds a remote proxy method parameter to a URL path variable.
- *
- * <p>
- * The value replaces the corresponding {@code {name}} template variable in the method's path.
- *
- * <p class='bjava'>
- * <ja>@Remote</ja>(path=<js>"/api/users"</js>)
- * <jk>public interface</jk> UserService {
- * <ja>@RemoteGet</ja>(<js>"/{id}"</js>)
- * String getUser(<ja>@Path</ja>(<js>"id"</js>) String id);
- * }
- * </p>
- *
- * <p>
- * <b>Beta — API subject to change:</b> This type is part of the next-generation REST client and HTTP stack
- * ({@code org.apache.juneau.ng.*}).
- *
- * @since 9.2.1
- */
-@Documented
-@Target(PARAMETER)
-@Retention(RUNTIME)
-public @interface Path {
-
- /**
- * The path variable name to replace.
- *
- * @return The path variable name. If empty, the parameter name is used (requires {@code -parameters} compiler flag).
- */
- String value() default "";
-}
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Query.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Query.java
deleted file mode 100644
index 0dd4081d62..0000000000
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/ng/http/remote/Query.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.ng.http.remote;
-
-import static java.lang.annotation.ElementType.*;
-import static java.lang.annotation.RetentionPolicy.*;
-
-import java.lang.annotation.*;
-
-/**
- * Binds a remote proxy method parameter to a URL query parameter.
- *
- * <p class='bjava'>
- * <ja>@Remote</ja>(path=<js>"/api/search"</js>)
- * <jk>public interface</jk> SearchService {
- * <ja>@RemoteGet</ja>
- * String search(<ja>@Query</ja>(<js>"q"</js>) String query, <ja>@Query</ja>(<js>"page"</js>) int page);
- * }
- * </p>
- *
- * <p>
- * <b>Beta — API subject to change:</b> This type is part of the next-generation REST client and HTTP stack
- * ({@code org.apache.juneau.ng.*}).
- *
- * @since 9.2.1
- */
-@Documented
-@Target(PARAMETER)
-@Retention(RUNTIME)
-public @interface Query {
-
- /**
- * The query parameter name.
- *
- * @return The name. If empty, the parameter name is used (requires {@code -parameters} compiler flag).
- */
- String value() default "";
-}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java
index 67c2d4544a..b17df14b95 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/FormDataArg.java
@@ -19,7 +19,6 @@ package org.apache.juneau.rest.arg;
import static org.apache.juneau.commons.utils.CollectionUtils.*;
import static org.apache.juneau.commons.utils.StringUtils.*;
import static org.apache.juneau.commons.utils.Utils.*;
-import static org.apache.juneau.http.annotation.FormDataAnnotation.*;
import java.util.*;
@@ -73,88 +72,48 @@ public class FormDataArg implements RestOpArg {
return null;
}
- /**
- * Gets the merged @FormData annotation combining class-level and parameter-level values.
- *
- * @param pi The parameter info.
- * @param paramName The form data parameter name.
- * @return Merged annotation, or null if no class-level defaults exist.
- */
- private static FormData getMergedFormData(ParameterInfo pi, String paramName) {
- // Get the declaring class
+ private static Optional<String> findName(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(FormData.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> isAnyNotBlank(x.value(), x.name()))
+ .findFirst()
+ .map(x -> firstNonBlank(x.name(), x.value()));
+ // @formatter:on
+ }
+
+ private static Optional<String> findDef(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(FormData.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> ne(x.def()))
+ .findFirst()
+ .map(FormData::def);
+ // @formatter:on
+ }
+
+ private static FormData getClassLevelFormData(ParameterInfo pi, String paramName) {
var declaringClass = pi.getMethod().getDeclaringClass();
if (declaringClass == null)
return null;
-
- // Find @Rest annotation on the class
var restAnnotation = declaringClass.getAnnotations(Rest.class).findFirst().map(AnnotationInfo::inner).orElse(null);
if (restAnnotation == null)
return null;
-
- // Find matching @FormData from class-level formDataParams array
- FormData classLevelFormData = null;
for (var f : restAnnotation.formDataParams()) {
var fName = firstNonEmpty(f.name(), f.value());
- if (eq(paramName, fName)) {
- classLevelFormData = f;
- break;
- }
- }
-
- if (classLevelFormData == null)
- return null;
-
- // Get parameter-level @FormData
- var paramFormData = AP.find(FormData.class, pi).stream().findFirst().map(AnnotationInfo::inner).orElse(null);
-
- if (paramFormData == null) {
- // No parameter-level @FormData, use class-level as-is
- return classLevelFormData;
+ if (eq(paramName, fName))
+ return f;
}
-
- // Merge the two annotations: parameter-level takes precedence
- return mergeAnnotations(classLevelFormData, paramFormData);
- }
-
- /**
- * Merges two @FormData annotations, with param-level taking precedence over class-level.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static FormData mergeAnnotations(FormData classLevel, FormData paramLevel) {
- return FormDataAnnotation.create().name(firstNonEmpty(paramLevel.name(), paramLevel.value(), classLevel.name(), classLevel.value()))
- .value(firstNonEmpty(paramLevel.value(), paramLevel.name(), classLevel.value(), classLevel.name())).def(firstNonEmpty(paramLevel.def(), classLevel.def()))
- .description(paramLevel.description().length > 0 ? paramLevel.description() : classLevel.description())
- .parser(paramLevel.parser() != HttpPartParser.Void.class ? paramLevel.parser() : classLevel.parser())
- .serializer(paramLevel.serializer() != HttpPartSerializer.Void.class ? paramLevel.serializer() : classLevel.serializer()).schema(mergeSchemas(classLevel.schema(), paramLevel.schema()))
- .build();
- }
-
- /**
- * Merges two @Schema annotations, with param-level taking precedence.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static Schema mergeSchemas(Schema classLevel, Schema paramLevel) {
- // If parameter has a non-default schema, use it; otherwise use class-level
- if (! SchemaAnnotation.empty(paramLevel))
- return paramLevel;
- return classLevel;
+ return null;
}
private final boolean multi;
-
private final HttpPartParser partParser;
-
private final HttpPartSchema schema;
-
private final String name;
private final String def;
-
private final ClassInfo type;
/**
@@ -164,17 +123,19 @@ public class FormDataArg implements RestOpArg {
* @param annotations The annotations to apply to any new part parsers.
*/
protected FormDataArg(ParameterInfo pi, AnnotationWorkList annotations) {
- // Get the form data parameter name
this.name = findName(pi).orElseThrow(() -> new ArgException(pi, "@FormData used without name or value"));
- // Check for class-level defaults and merge if found
- FormData mergedFormData = getMergedFormData(pi, name);
+ var classLevelFormData = getClassLevelFormData(pi, name);
+
+ var schemaBuilder = HttpPartSchema.create();
+ if (classLevelFormData != null)
+ schemaBuilder.apply(classLevelFormData);
+ schemaBuilder.applyAll(FormData.class, pi);
+ this.schema = schemaBuilder.build();
- // Use merged form data annotation for all lookups
- this.def = nn(mergedFormData) && ! mergedFormData.def().isEmpty() ? mergedFormData.def() : findDef(pi).orElse(null);
+ this.def = findDef(pi).or(() -> Optional.ofNullable(classLevelFormData).filter(f -> ne(f.def())).map(FormData::def)).orElse(null);
this.type = pi.getParameterType();
- this.schema = nn(mergedFormData) ? HttpPartSchema.create(mergedFormData) : HttpPartSchema.create(FormData.class, pi);
- Class<? extends HttpPartParser> pp = schema.getParser();
+ var pp = schema.getParser();
this.partParser = nn(pp) ? HttpPartParser.creator().type(pp).apply(annotations).create() : null;
this.multi = schema.getCollectionFormat() == HttpPartCollectionFormat.MULTI;
@@ -188,10 +149,10 @@ public class FormDataArg implements RestOpArg {
})
@Override /* Overridden from RestOpArg */
public Object resolve(RestOpSession opSession) throws Exception {
- RestRequest req = opSession.getRequest();
- HttpPartParserSession ps = partParser == null ? req.getPartParserSession() : partParser.getPartSession();
- RequestFormParams rh = req.getFormParams();
- BeanSession bs = req.getBeanSession();
+ var req = opSession.getRequest();
+ var ps = partParser == null ? req.getPartParserSession() : partParser.getPartSession();
+ var rh = req.getFormParams();
+ var bs = req.getBeanSession();
var cm = bs.getClassMeta(type.innerType());
if (multi) {
@@ -215,4 +176,4 @@ public class FormDataArg implements RestOpArg {
return rh.getLast(name).parser(ps).schema(schema).def(def).as(type.innerType()).orElse(null);
}
-}
\ No newline at end of file
+}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java
index 38a5666d7b..e4081a588e 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/HeaderArg.java
@@ -19,7 +19,6 @@ package org.apache.juneau.rest.arg;
import static org.apache.juneau.commons.utils.CollectionUtils.*;
import static org.apache.juneau.commons.utils.StringUtils.*;
import static org.apache.juneau.commons.utils.Utils.*;
-import static org.apache.juneau.http.annotation.HeaderAnnotation.*;
import java.util.*;
@@ -114,93 +113,48 @@ public class HeaderArg implements RestOpArg {
return null;
}
- /**
- * Gets the merged @Header annotation combining class-level and parameter-level values.
- *
- * @param pi The parameter info.
- * @param paramName The header name.
- * @return Merged annotation, or null if no class-level defaults exist.
- */
- private static Header getMergedHeader(ParameterInfo pi, String paramName) {
- // Get the declaring class
+ private static Optional<String> findName(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(Header.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> isAnyNotBlank(x.value(), x.name()))
+ .findFirst()
+ .map(x -> firstNonBlank(x.name(), x.value()));
+ // @formatter:on
+ }
+
+ private static Optional<String> findDef(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(Header.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> ne(x.def()))
+ .findFirst()
+ .map(Header::def);
+ // @formatter:on
+ }
+
+ private static Header getClassLevelHeader(ParameterInfo pi, String paramName) {
var declaringClass = pi.getMethod().getDeclaringClass();
if (declaringClass == null)
return null;
-
- // Find @Rest annotation on the class
var restAnnotation = declaringClass.getAnnotations(Rest.class).findFirst().map(AnnotationInfo::inner).orElse(null);
if (restAnnotation == null)
return null;
-
- // Find matching @Header from class-level headerParams array
- Header classLevelHeader = null;
for (var h : restAnnotation.headerParams()) {
var hName = firstNonEmpty(h.name(), h.value());
- if (paramName.equals(hName)) {
- classLevelHeader = h;
- break;
- }
- }
-
- if (classLevelHeader == null)
- return null;
-
- // Get parameter-level @Header
- var paramHeader = AP.find(Header.class, pi).stream().findFirst().map(AnnotationInfo::inner).orElse(null);
-
- if (paramHeader == null) {
- // No parameter-level @Header, use class-level as-is
- return classLevelHeader;
+ if (paramName.equals(hName))
+ return h;
}
-
- // Merge the two annotations: parameter-level takes precedence
- return mergeAnnotations(classLevelHeader, paramHeader);
- }
-
- /**
- * Merges two @Header annotations, with param-level taking precedence over class-level.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static Header mergeAnnotations(Header classLevel, Header paramLevel) {
- // @formatter:off
- return HeaderAnnotation.create()
- .name(firstNonEmpty(paramLevel.name(), paramLevel.value(), classLevel.name(), classLevel.value()))
- .value(firstNonEmpty(paramLevel.value(), paramLevel.name(), classLevel.value(), classLevel.name()))
- .def(firstNonEmpty(paramLevel.def(), classLevel.def()))
- .description(paramLevel.description().length > 0 ? paramLevel.description() : classLevel.description())
- .parser(paramLevel.parser() != HttpPartParser.Void.class ? paramLevel.parser() : classLevel.parser())
- .serializer(paramLevel.serializer() != HttpPartSerializer.Void.class ? paramLevel.serializer() : classLevel.serializer())
- .schema(mergeSchemas(classLevel.schema(), paramLevel.schema()))
- .build();
- // @formatter:on
- }
-
- /**
- * Merges two @Schema annotations, with param-level taking precedence.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static Schema mergeSchemas(Schema classLevel, Schema paramLevel) {
- // If parameter has a non-default schema, use it; otherwise use class-level
- if (! SchemaAnnotation.empty(paramLevel))
- return paramLevel;
- return classLevel;
+ return null;
}
private final HttpPartParser partParser;
-
private final HttpPartSchema schema;
-
private final boolean multi;
-
private final String name;
private final String def;
-
private final ClassInfo type;
/**
@@ -210,16 +164,18 @@ public class HeaderArg implements RestOpArg {
* @param annotations The annotations to apply to any new part parsers.
*/
protected HeaderArg(ParameterInfo pi, AnnotationWorkList annotations) {
- // Get the header name from the parameter
this.name = findName(pi).orElseThrow(() -> new ArgException(pi, "@Header used without name or value"));
- // Check for class-level defaults and merge if found
- var mergedHeader = getMergedHeader(pi, name);
+ var classLevelHeader = getClassLevelHeader(pi, name);
+
+ var schemaBuilder = HttpPartSchema.create();
+ if (classLevelHeader != null)
+ schemaBuilder.apply(classLevelHeader);
+ schemaBuilder.applyAll(Header.class, pi);
+ this.schema = schemaBuilder.build();
- // Use merged header annotation for all lookups
- this.def = nn(mergedHeader) && ! mergedHeader.def().isEmpty() ? mergedHeader.def() : findDef(pi).orElse(null);
+ this.def = findDef(pi).or(() -> Optional.ofNullable(classLevelHeader).filter(h -> ne(h.def())).map(Header::def)).orElse(null);
this.type = pi.getParameterType();
- this.schema = nn(mergedHeader) ? HttpPartSchema.create(mergedHeader) : HttpPartSchema.create(Header.class, pi);
var pp = schema.getParser();
this.partParser = nn(pp) ? HttpPartParser.creator().type(pp).apply(annotations).create() : null;
this.multi = schema.getCollectionFormat() == HttpPartCollectionFormat.MULTI;
@@ -261,4 +217,4 @@ public class HeaderArg implements RestOpArg {
return rh.getLast(name).parser(ps).schema(schema).def(def).as(type.innerType()).orElse(null);
}
-}
\ No newline at end of file
+}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java
index 48dbfab43d..c9310a06e1 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathArg.java
@@ -19,12 +19,11 @@ package org.apache.juneau.rest.arg;
import static org.apache.juneau.Constants.*;
import static org.apache.juneau.commons.utils.StringUtils.*;
import static org.apache.juneau.commons.utils.Utils.*;
-import static org.apache.juneau.http.annotation.PathAnnotation.*;
import java.lang.reflect.*;
+import java.util.*;
import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.commons.reflect.*;
import org.apache.juneau.http.annotation.*;
@@ -72,82 +71,41 @@ public class PathArg implements RestOpArg {
return null;
}
- /**
- * Gets the merged @Path annotation combining class-level and parameter-level values.
- *
- * @param pi The parameter info.
- * @param paramName The path parameter name.
- * @return Merged annotation, or null if no class-level defaults exist.
- */
- private static Path getMergedPath(ParameterInfo pi, String paramName) {
- // Get the declaring class
+ private static Optional<String> findName(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(Path.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> isAnyNotBlank(x.value(), x.name()))
+ .findFirst()
+ .map(x -> firstNonBlank(x.name(), x.value()));
+ // @formatter:on
+ }
+
+ private static Optional<String> findDef(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(Path.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> ne(x.def()) && neq(NONE, x.def()))
+ .findFirst()
+ .map(Path::def);
+ // @formatter:on
+ }
+
+ private static Path getClassLevelPath(ParameterInfo pi, String paramName) {
var declaringClass = pi.getMethod().getDeclaringClass();
if (declaringClass == null)
return null;
-
- // Find @Rest annotation on the class
var restAnnotation = declaringClass.getAnnotations(Rest.class).findFirst().map(AnnotationInfo::inner).orElse(null);
if (restAnnotation == null)
return null;
-
- // Find matching @Path from class-level pathParams array
- Path classLevelPath = null;
for (var p : restAnnotation.pathParams()) {
var pName = firstNonEmpty(p.name(), p.value());
- if (paramName.equals(pName)) {
- classLevelPath = p;
- break;
- }
- }
-
- if (classLevelPath == null)
- return null;
-
- // Get parameter-level @Path
- var paramPath = AP.find(Path.class, pi).stream().findFirst().map(AnnotationInfo::inner).orElse(null);
-
- if (paramPath == null) {
- // No parameter-level @Path, use class-level as-is
- return classLevelPath;
+ if (paramName.equals(pName))
+ return p;
}
-
- // Merge the two annotations: parameter-level takes precedence
- return mergeAnnotations(classLevelPath, paramPath);
- }
-
- /**
- * Merges two @Path annotations, with param-level taking precedence over class-level.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static Path mergeAnnotations(Path classLevel, Path paramLevel) {
- // @formatter:off
- return PathAnnotation.create()
- .name(firstNonEmpty(paramLevel.name(), paramLevel.value(), classLevel.name(), classLevel.value()))
- .value(firstNonEmpty(paramLevel.value(), paramLevel.name(), classLevel.value(), classLevel.name()))
- .def(firstNonEmpty(paramLevel.def(), classLevel.def()))
- .description(paramLevel.description().length > 0 ? paramLevel.description() : classLevel.description())
- .parser(paramLevel.parser() != HttpPartParser.Void.class ? paramLevel.parser() : classLevel.parser())
- .serializer(paramLevel.serializer() != HttpPartSerializer.Void.class ? paramLevel.serializer() : classLevel.serializer())
- .schema(mergeSchemas(classLevel.schema(), paramLevel.schema()))
- .build();
- // @formatter:on
- }
-
- /**
- * Merges two @Schema annotations, with param-level taking precedence.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static Schema mergeSchemas(Schema classLevel, Schema paramLevel) {
- // If parameter has a non-default schema, use it; otherwise use class-level
- if (! SchemaAnnotation.empty(paramLevel))
- return paramLevel;
- return classLevel;
+ return null;
}
private final HttpPartParser partParser;
@@ -164,17 +122,18 @@ public class PathArg implements RestOpArg {
* @param pathMatcher Path matcher for the specified method.
*/
protected PathArg(ParameterInfo paramInfo, AnnotationWorkList annotations, UrlPathMatcher pathMatcher) {
- // Get the path parameter name
this.name = getName(paramInfo, pathMatcher);
- // Check for class-level defaults and merge if found
- var mergedPath = getMergedPath(paramInfo, name);
+ var classLevelPath = getClassLevelPath(paramInfo, name);
+
+ var schemaBuilder = HttpPartSchema.create();
+ if (classLevelPath != null)
+ schemaBuilder.apply(classLevelPath);
+ schemaBuilder.applyAll(Path.class, paramInfo);
+ this.schema = schemaBuilder.build();
- // Use merged path annotation for all lookups
- var pathDef = nn(mergedPath) ? mergedPath.def() : null;
- this.def = nn(pathDef) && neq(NONE, pathDef) ? pathDef : findDef(paramInfo).orElse(null);
+ this.def = findDef(paramInfo).or(() -> Optional.ofNullable(classLevelPath).filter(p -> ne(p.def()) && neq(NONE, p.def())).map(Path::def)).orElse(null);
this.type = paramInfo.getParameterType().innerType();
- this.schema = nn(mergedPath) ? HttpPartSchema.create(mergedPath) : HttpPartSchema.create(Path.class, paramInfo);
var pp = schema.getParser();
this.partParser = nn(pp) ? HttpPartParser.creator().type(pp).apply(annotations).create() : null;
}
@@ -210,7 +169,6 @@ public class PathArg implements RestOpArg {
if (vars.length <= idx)
throw new ArgException(pi, "Number of attribute parameters exceeds the number of URL pattern variables. vars.length={0}, idx={1}", vars.length, idx);
- // Check for {#} variables.
var idxs = String.valueOf(idx);
for (var v : vars)
if (isNumeric(v) && v.equals(idxs))
@@ -220,4 +178,4 @@ public class PathArg implements RestOpArg {
}
throw new ArgException(pi, "@Path used without name or value");
}
-}
\ No newline at end of file
+}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathRemainderArg.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathRemainderArg.java
index 4355a44551..778ec1b868 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathRemainderArg.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/PathRemainderArg.java
@@ -17,9 +17,9 @@
package org.apache.juneau.rest.arg;
import static org.apache.juneau.commons.utils.Utils.*;
-import static org.apache.juneau.http.annotation.PathRemainderAnnotation.*;
import java.lang.reflect.*;
+import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.commons.reflect.*;
@@ -79,6 +79,17 @@ public class PathRemainderArg implements RestOpArg {
return null;
}
+ private static Optional<String> findDef(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(PathRemainder.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> ne(x.def()))
+ .findFirst()
+ .map(PathRemainder::def);
+ // @formatter:on
+ }
+
private final HttpPartParser partParser;
private final HttpPartSchema schema;
private final String def;
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java
index e74ed6d0d0..d1aa64ffb2 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/QueryArg.java
@@ -19,7 +19,6 @@ package org.apache.juneau.rest.arg;
import static org.apache.juneau.commons.utils.CollectionUtils.*;
import static org.apache.juneau.commons.utils.StringUtils.*;
import static org.apache.juneau.commons.utils.Utils.*;
-import static org.apache.juneau.http.annotation.QueryAnnotation.*;
import java.util.*;
@@ -73,82 +72,41 @@ public class QueryArg implements RestOpArg {
return null;
}
- /**
- * Gets the merged @Query annotation combining class-level and parameter-level values.
- *
- * @param pi The parameter info.
- * @param paramName The query parameter name.
- * @return Merged annotation, or null if no class-level defaults exist.
- */
- private static Query getMergedQuery(ParameterInfo pi, String paramName) {
- // Get the declaring class
+ private static Optional<String> findName(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(Query.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> isAnyNotBlank(x.value(), x.name()))
+ .findFirst()
+ .map(x -> firstNonBlank(x.name(), x.value()));
+ // @formatter:on
+ }
+
+ private static Optional<String> findDef(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(Query.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> ne(x.def()))
+ .findFirst()
+ .map(Query::def);
+ // @formatter:on
+ }
+
+ private static Query getClassLevelQuery(ParameterInfo pi, String paramName) {
var declaringClass = pi.getMethod().getDeclaringClass();
if (declaringClass == null)
return null;
-
- // Find @Rest annotation on the class
var restAnnotation = declaringClass.getAnnotations(Rest.class).findFirst().map(AnnotationInfo::inner).orElse(null);
if (restAnnotation == null)
return null;
-
- // Find matching @Query from class-level queryParams array
- Query classLevelQuery = null;
for (var q : restAnnotation.queryParams()) {
var qName = firstNonEmpty(q.name(), q.value());
- if (paramName.equals(qName)) {
- classLevelQuery = q;
- break;
- }
- }
-
- if (classLevelQuery == null)
- return null;
-
- // Get parameter-level @Query
- var paramQuery = AP.find(Query.class, pi).stream().findFirst().map(AnnotationInfo::inner).orElse(null);
-
- if (paramQuery == null) {
- // No parameter-level @Query, use class-level as-is
- return classLevelQuery;
+ if (paramName.equals(qName))
+ return q;
}
-
- // Merge the two annotations: parameter-level takes precedence
- return mergeAnnotations(classLevelQuery, paramQuery);
- }
-
- /**
- * Merges two @Query annotations, with param-level taking precedence over class-level.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static Query mergeAnnotations(Query classLevel, Query paramLevel) {
- // @formatter:off
- return QueryAnnotation.create()
- .name(firstNonEmpty(paramLevel.name(), paramLevel.value(), classLevel.name(), classLevel.value()))
- .value(firstNonEmpty(paramLevel.value(), paramLevel.name(), classLevel.value(), classLevel.name()))
- .def(firstNonEmpty(paramLevel.def(), classLevel.def()))
- .description(paramLevel.description().length > 0 ? paramLevel.description() : classLevel.description())
- .parser(paramLevel.parser() != HttpPartParser.Void.class ? paramLevel.parser() : classLevel.parser())
- .serializer(paramLevel.serializer() != HttpPartSerializer.Void.class ? paramLevel.serializer() : classLevel.serializer())
- .schema(mergeSchemas(classLevel.schema(), paramLevel.schema()))
- .build();
- // @formatter:on
- }
-
- /**
- * Merges two @Schema annotations, with param-level taking precedence.
- *
- * @param classLevel The class-level default.
- * @param paramLevel The parameter-level override.
- * @return Merged annotation.
- */
- private static Schema mergeSchemas(Schema classLevel, Schema paramLevel) {
- // If parameter has a non-default schema, use it; otherwise use class-level
- if (! SchemaAnnotation.empty(paramLevel))
- return paramLevel;
- return classLevel;
+ return null;
}
private final boolean multi;
@@ -165,16 +123,18 @@ public class QueryArg implements RestOpArg {
* @param annotations The annotations to apply to any new part parsers.
*/
protected QueryArg(ParameterInfo pi, AnnotationWorkList annotations) {
- // Get the query name from the parameter
this.name = findName(pi).orElseThrow(() -> new ArgException(pi, "@Query used without name or value"));
- // Check for class-level defaults and merge if found
- var mergedQuery = getMergedQuery(pi, name);
+ var classLevelQuery = getClassLevelQuery(pi, name);
+
+ var schemaBuilder = HttpPartSchema.create();
+ if (classLevelQuery != null)
+ schemaBuilder.apply(classLevelQuery);
+ schemaBuilder.applyAll(Query.class, pi);
+ this.schema = schemaBuilder.build();
- // Use merged query annotation for all lookups
- this.def = nn(mergedQuery) && ! mergedQuery.def().isEmpty() ? mergedQuery.def() : findDef(pi).orElse(null);
+ this.def = findDef(pi).or(() -> Optional.ofNullable(classLevelQuery).filter(q -> ne(q.def())).map(Query::def)).orElse(null);
this.type = pi.getParameterType();
- this.schema = nn(mergedQuery) ? HttpPartSchema.create(mergedQuery) : HttpPartSchema.create(Query.class, pi);
var pp = schema.getParser();
this.partParser = nn(pp) ? HttpPartParser.creator().type(pp).apply(annotations).create() : null;
this.multi = schema.getCollectionFormat() == HttpPartCollectionFormat.MULTI;
@@ -216,4 +176,4 @@ public class QueryArg implements RestOpArg {
return rh.getLast(name).parser(ps).schema(schema).def(def).as(type.innerType()).orElse(null);
}
-}
\ No newline at end of file
+}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/ResponseHeaderArg.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/ResponseHeaderArg.java
index 9543633617..2ef34fbda1 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/ResponseHeaderArg.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/arg/ResponseHeaderArg.java
@@ -16,10 +16,11 @@
*/
package org.apache.juneau.rest.arg;
+import static org.apache.juneau.commons.utils.StringUtils.*;
import static org.apache.juneau.commons.utils.Utils.*;
-import static org.apache.juneau.http.annotation.HeaderAnnotation.*;
import java.lang.reflect.*;
+import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.annotation.*;
@@ -64,6 +65,17 @@ public class ResponseHeaderArg implements RestOpArg {
return null;
}
+ private static Optional<String> findName(ParameterInfo pi) {
+ // @formatter:off
+ return AP.find(Header.class, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> isAnyNotBlank(x.value(), x.name()))
+ .findFirst()
+ .map(x -> firstNonBlank(x.name(), x.value()));
+ // @formatter:on
+ }
+
final ResponsePartMeta meta;
final String name;
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java
index 2bc7a5bc8a..93f449f646 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/swagger/BasicSwaggerProviderSession.java
@@ -476,7 +476,7 @@ public class BasicSwaggerProviderSession {
addBodyExamples(sm, param, false, type, locale);
} else if (ap.has(Query.class, mpi)) {
- var name = QueryAnnotation.findName(mpi).orElse(null);
+ var name = findAnnotationName(ap, Query.class, mpi).orElse(null);
var param = paramMap.getMap(QUERY + "." + name, true).append(SWAGGER_name, name).append(SWAGGER_in, QUERY);
rstream(ap.find(Schema.class, mpi)).forEach(x -> merge(param, x.inner()));
rstream(ap.find(Query.class, mpi)).forEach(x -> merge(param, x.inner().schema()));
@@ -484,7 +484,7 @@ public class BasicSwaggerProviderSession {
addParamExample(sm, param, QUERY, type);
} else if (ap.has(FormData.class, mpi)) {
- var name = FormDataAnnotation.findName(mpi).orElse(null);
+ var name = findAnnotationName(ap, FormData.class, mpi).orElse(null);
var param = paramMap.getMap(FORM_DATA + "." + name, true).append(SWAGGER_name, name).append(SWAGGER_in, FORM_DATA);
rstream(ap.find(Schema.class, mpi)).forEach(x -> merge(param, x.inner()));
rstream(ap.find(FormData.class, mpi)).forEach(x -> merge(param, x.inner().schema()));
@@ -492,7 +492,7 @@ public class BasicSwaggerProviderSession {
addParamExample(sm, param, FORM_DATA, type);
} else if (ap.has(Header.class, mpi)) {
- var name = HeaderAnnotation.findName(mpi).orElse(null);
+ var name = findAnnotationName(ap, Header.class, mpi).orElse(null);
var param = paramMap.getMap(HEADER + "." + name, true).append(SWAGGER_name, name).append(SWAGGER_in, HEADER);
rstream(ap.find(Schema.class, mpi)).forEach(x -> merge(param, x.inner()));
rstream(ap.find(Header.class, mpi)).forEach(x -> merge(param, x.inner().schema()));
@@ -500,7 +500,7 @@ public class BasicSwaggerProviderSession {
addParamExample(sm, param, HEADER, type);
} else if (ap.has(Path.class, mpi)) {
- var name = PathAnnotation.findName(mpi).orElse(null);
+ var name = findAnnotationName(ap, Path.class, mpi).orElse(null);
var param = paramMap.getMap(PATH + "." + name, true).append(SWAGGER_name, name).append(SWAGGER_in, PATH);
rstream(ap.find(Schema.class, mpi)).forEach(x -> merge(param, x.inner()));
rstream(ap.find(Path.class, mpi)).forEach(x -> merge(param, x.inner().schema()));
@@ -602,7 +602,7 @@ public class BasicSwaggerProviderSession {
var la = rstream(ap.find(Header.class, mpi)).map(AnnotationInfo::inner).toList();
var la2 = rstream(ap.find(StatusCode.class, mpi)).map(AnnotationInfo::inner).toList();
var codes = getCodes(la2, 200);
- var name = HeaderAnnotation.findName(mpi).orElse(null);
+ var name = findAnnotationName(ap, Header.class, mpi).orElse(null);
var type = Value.unwrap(mpi.getParameterType().innerType());
for (var a : la) {
if (! isMulti(a)) {
@@ -1258,6 +1258,31 @@ public class BasicSwaggerProviderSession {
return nullIfEmpty(om);
}
+ private static Optional<String> findAnnotationName(AnnotationProvider ap, Class<? extends java.lang.annotation.Annotation> type, ParameterInfo pi) {
+ // @formatter:off
+ return ap.find(type, pi)
+ .stream()
+ .map(AnnotationInfo::inner)
+ .filter(x -> {
+ var nv = getNameValue(x);
+ return isAnyNotBlank(nv[0], nv[1]);
+ })
+ .findFirst()
+ .map(x -> {
+ var nv = getNameValue(x);
+ return firstNonBlank(nv[0], nv[1]);
+ });
+ // @formatter:on
+ }
+
+ private static String[] getNameValue(java.lang.annotation.Annotation a) {
+ if (a instanceof Query a2) return new String[]{a2.name(), a2.value()};
+ if (a instanceof Header a2) return new String[]{a2.name(), a2.value()};
+ if (a instanceof FormData a2) return new String[]{a2.name(), a2.value()};
+ if (a instanceof Path a2) return new String[]{a2.name(), a2.value()};
+ return new String[]{"", ""};
+ }
+
private static Set<String> toSet(String[] ss) {
if (ss.length == 0)
return null;
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java
index 4d135348e1..fafd7f0c07 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/AnnotationUtils_Test.java
@@ -25,8 +25,6 @@ import java.lang.annotation.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
-import org.apache.juneau.commons.utils.*;
-import org.apache.juneau.oapi.*;
import org.junit.jupiter.api.*;
@SuppressWarnings({
@@ -49,12 +47,10 @@ class AnnotationUtils_Test extends TestBase {
Items items() default @Items;
}
- @Content
@Response
- @Header
@X1
public static class A1 {
- @Query @Header @FormData @Path @Schema
+ @Schema
public int f1;
}
@@ -62,15 +58,6 @@ class AnnotationUtils_Test extends TestBase {
public int f1;
}
- @Test void a01_Body() {
- assertBean(body().build().annotationType(), "simpleName", "Content");
-
- assertTrue(ContentAnnotation.empty(A1.class.getAnnotation(Content.class)));
- assertTrue(ContentAnnotation.empty(A2.class.getAnnotation(Content.class)));
- assertTrue(ContentAnnotation.empty(body().build()));
- assertTrue(ContentAnnotation.empty((Content)null));
- }
-
@Test void a02_Contact() {
var x1 = A1.class.getAnnotation(X1.class);
@@ -85,71 +72,6 @@ class AnnotationUtils_Test extends TestBase {
assertFalse(ContactAnnotation.empty(contact().url("foo").build()));
}
- @Test void a03_FormData() throws Exception {
- var f1 = A1.class.getField("f1");
- var f2 = A2.class.getField("f1");
-
- assertBean(formData().build().annotationType(), "simpleName", "FormData");
-
- assertTrue(FormDataAnnotation.empty(f1.getAnnotation(FormData.class)));
- assertTrue(FormDataAnnotation.empty(f2.getAnnotation(FormData.class)));
- assertTrue(FormDataAnnotation.empty((FormData)null));
- assertTrue(FormDataAnnotation.empty(formData().build()));
-
- assertFalse(FormDataAnnotation.empty(formData().name("foo").build()));
- assertFalse(FormDataAnnotation.empty(formData().parser(OpenApiParser.class).build()));
- assertFalse(FormDataAnnotation.empty(formData().serializer(OpenApiSerializer.class).build()));
- assertFalse(FormDataAnnotation.empty(formData().value("foo").build()));
- }
-
- @Test void a04_HasFormData() {
- assertBean(hasFormData().build().annotationType(), "simpleName", "HasFormData");
-
- assertEquals("foo", hasFormData().name("foo").build().name());
- assertEquals("foo", hasFormData().value("foo").build().value());
- }
-
- @Test void a05_Query() throws Exception {
- var f1 = A1.class.getField("f1");
- var f2 = A2.class.getField("f1");
-
- assertBean(query().build().annotationType(), "simpleName", "Query");
-
- assertTrue(QueryAnnotation.empty(f1.getAnnotation(Query.class)));
- assertTrue(QueryAnnotation.empty(f2.getAnnotation(Query.class)));
- assertTrue(QueryAnnotation.empty((Query)null));
- assertTrue(QueryAnnotation.empty(query().build()));
-
- assertFalse(QueryAnnotation.empty(query().name("foo").build()));
- assertFalse(QueryAnnotation.empty(query().parser(OpenApiParser.class).build()));
- assertFalse(QueryAnnotation.empty(query().serializer(OpenApiSerializer.class).build()));
- assertFalse(QueryAnnotation.empty(query().value("foo").build()));
- }
-
- @Test void a06_HasQuery() {
- assertBean(hasQuery().build().annotationType(), "simpleName", "HasQuery");
-
- assertEquals("foo", hasQuery().name("foo").build().name());
- assertEquals("foo", hasQuery().value("foo").build().value());
- }
-
- @Test void a07_Header() throws Exception {
- var f1 = A1.class.getField("f1");
- var f2 = A2.class.getField("f1");
-
- assertBean(header().build().annotationType(), "simpleName", "Header");
-
- assertTrue(HeaderAnnotation.empty(f1.getAnnotation(Header.class)));
- assertTrue(HeaderAnnotation.empty(f2.getAnnotation(Header.class)));
- assertTrue(HeaderAnnotation.empty((Header)null));
- assertTrue(HeaderAnnotation.empty(header().build()));
-
- assertFalse(HeaderAnnotation.empty(header().name("foo").build()));
- assertFalse(HeaderAnnotation.empty(header().parser(OpenApiParser.class).build()));
- assertFalse(HeaderAnnotation.empty(header().serializer(OpenApiSerializer.class).build()));
- assertFalse(HeaderAnnotation.empty(header().value("foo").build()));
- }
-
@Test void a08_License() {
var x = A1.class.getAnnotation(X1.class);
@@ -163,30 +85,6 @@ class AnnotationUtils_Test extends TestBase {
assertFalse(LicenseAnnotation.empty(license().url("foo").build()));
}
- @Test void a09_Path() throws Exception {
- var f1 = A1.class.getField("f1");
- var f2 = A2.class.getField("f1");
-
- assertBean(path().build().annotationType(), "simpleName", "Path");
-
- assertTrue(PathAnnotation.empty(f1.getAnnotation(Path.class)));
- assertTrue(PathAnnotation.empty(f2.getAnnotation(Path.class)));
- assertTrue(PathAnnotation.empty((Path)null));
- assertTrue(PathAnnotation.empty(path().build()));
-
- assertFalse(PathAnnotation.empty(path().name("foo").build()));
- assertFalse(PathAnnotation.empty(path().parser(OpenApiParser.class).build()));
- assertFalse(PathAnnotation.empty(path().serializer(OpenApiSerializer.class).build()));
- assertFalse(PathAnnotation.empty(path().value("foo").build()));
- }
-
- @Test void a10_Request() {
- assertBean(request().build().annotationType(), "simpleName", "Request");
-
- assertString("org.apache.juneau.oapi.OpenApiParser", request().parser(OpenApiParser.class).build().parser().getName());
- assertString("org.apache.juneau.oapi.OpenApiSerializer", request().serializer(OpenApiSerializer.class).build().serializer().getName());
- }
-
@Test void a11_Response() {
assertBean(response().build().annotationType(), "simpleName", "Response");
@@ -196,14 +94,7 @@ class AnnotationUtils_Test extends TestBase {
assertTrue(ResponseAnnotation.empty((Response)null));
assertFalse(ResponseAnnotation.empty(response().examples(a("foo")).build()));
- assertFalse(ResponseAnnotation.empty(response().headers(CollectionUtils.a(header().name("foo").build())).build()));
- assertFalse(ResponseAnnotation.empty(response().parser(OpenApiParser.class).build()));
assertFalse(ResponseAnnotation.empty(response().schema(schema().$ref("foo").build()).build()));
- assertFalse(ResponseAnnotation.empty(response().serializer(OpenApiSerializer.class).build()));
- }
-
- @Test void a14_ResponseStatus() {
- assertBean(responseCode().build().annotationType(), "simpleName", "StatusCode");
}
@Test void a15_Tag() {
@@ -378,54 +269,18 @@ class AnnotationUtils_Test extends TestBase {
// Helper methods.
//-----------------------------------------------------------------------------------------------------------------
- private static ContentAnnotation.Builder body() {
- return ContentAnnotation.create();
- }
-
private static ContactAnnotation.Builder contact() {
return ContactAnnotation.create();
}
- private static FormDataAnnotation.Builder formData() {
- return FormDataAnnotation.create();
- }
-
- private static HasFormDataAnnotation.Builder hasFormData() {
- return HasFormDataAnnotation.create();
- }
-
- private static QueryAnnotation.Builder query() {
- return QueryAnnotation.create();
- }
-
- private static HasQueryAnnotation.Builder hasQuery() {
- return HasQueryAnnotation.create();
- }
-
- private static HeaderAnnotation.Builder header() {
- return HeaderAnnotation.create();
- }
-
private static LicenseAnnotation.Builder license() {
return LicenseAnnotation.create();
}
- private static PathAnnotation.Builder path() {
- return PathAnnotation.create();
- }
-
- private static RequestAnnotation.Builder request() {
- return RequestAnnotation.create();
- }
-
private static ResponseAnnotation.Builder response() {
return ResponseAnnotation.create();
}
- private static StatusCodeAnnotation.Builder responseCode() {
- return StatusCodeAnnotation.create();
- }
-
private static TagAnnotation.Builder tag() {
return TagAnnotation.create();
}
@@ -449,4 +304,4 @@ class AnnotationUtils_Test extends TestBase {
private static String[] a(String...s) {
return s;
}
-}
\ No newline at end of file
+}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ContentAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ContentAnnotation_Test.java
deleted file mode 100644
index eaf48a577f..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ContentAnnotation_Test.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.junit.jupiter.api.*;
-
-@SuppressWarnings({
- "java:S1186" // Empty test method intentional for framework testing
-})
-class ContentAnnotation_Test extends TestBase {
-
- private static final String CNAME = ContentAnnotation_Test.class.getName();
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- Content a1 = ContentAnnotation.create()
- .description("a")
- .on("b")
- .onClass(X1.class)
- .build();
-
- Content a2 = ContentAnnotation.create()
- .description("a")
- .on("b")
- .onClass(X1.class)
- .build();
-
- @Test void a01_basic() {
- assertBean(a1, "description,on,onClass{length,#{simpleName}},schema{description}", "[a],[b],{1,[{X1}]},{[]}");
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() throws Exception {
- var c1 = ContentAnnotation.create(C1.class).on(C2.class).build();
- var c2 = ContentAnnotation.create("a").on("b").build();
- var c4 = ContentAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Comparison with declared annotations.
- //------------------------------------------------------------------------------------------------------------------
-
- @Content(
- description={ "a" },
- on="b",
- onClass=X1.class
- )
- public static class D1 {}
- Content d1 = D1.class.getAnnotationsByType(Content.class)[0];
-
- @Content(
- description={ "a" },
- on="b",
- onClass=X1.class
- )
- public static class D2 {}
- Content d2 = D2.class.getAnnotationsByType(Content.class)[0];
-
- @Test void d01_comparisonWithDeclarativeAnnotations() {
- assertEqualsAll(a1, d1, d2);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/FormDataAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/FormDataAnnotation_Test.java
deleted file mode 100644
index a80627d79d..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/FormDataAnnotation_Test.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.oapi.*;
-import org.junit.jupiter.api.*;
-
-@SuppressWarnings({
- "java:S1186" // Empty test method intentional for framework testing
-})
-class FormDataAnnotation_Test extends TestBase {
-
- private static final String CNAME = FormDataAnnotation_Test.class.getName();
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- FormData a1 = FormDataAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- FormData a2 = FormDataAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- @Test void a01_basic() {
- assertBean(
- a1,
- "def,description,name,on,onClass{#{simpleName}},parser{simpleName},schema{description},serializer{simpleName},value",
- "a,[b],c,[d],{[{X1}]},{OpenApiParser},{[]},{OpenApiSerializer},e"
- );
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() throws Exception {
- var c1 = FormDataAnnotation.create(C1.class).on(C2.class).build();
- var c2 = FormDataAnnotation.create("a").on("b").build();
- var c3 = FormDataAnnotation.create().on(C1.class.getField("f1")).on(C2.class.getField("f2")).build();
- var c4 = FormDataAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- assertBean(c3, "on", "["+CNAME+"$C1.f1,"+CNAME+"$C2.f2]");
- assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Comparison with declared annotations.
- //------------------------------------------------------------------------------------------------------------------
-
- @FormData(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D1 {}
- FormData d1 = D1.class.getAnnotationsByType(FormData.class)[0];
-
- @FormData(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D2 {}
- FormData d2 = D2.class.getAnnotationsByType(FormData.class)[0];
-
- @Test void d01_comparisonWithDeclarativeAnnotations() {
- assertEqualsAll(a1, d1, d2);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasFormDataAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasFormDataAnnotation_Test.java
deleted file mode 100644
index e85b2e8e2b..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasFormDataAnnotation_Test.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.junit.jupiter.api.*;
-
-class HasFormDataAnnotation_Test extends TestBase {
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- HasFormData a1 = HasFormDataAnnotation.create()
- .description("a")
- .name("b")
- .value("c")
- .build();
-
- HasFormData a2 = HasFormDataAnnotation.create()
- .description("a")
- .name("b")
- .value("c")
- .build();
-
- @Test void a01_basic() {
- assertBean(a1, "description,name,value", "[a],b,c");
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasQueryAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasQueryAnnotation_Test.java
deleted file mode 100644
index 0e5fc9b9fa..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HasQueryAnnotation_Test.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.junit.jupiter.api.*;
-
-class HasQueryAnnotation_Test extends TestBase {
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- HasQuery a1 = HasQueryAnnotation.create()
- .description("a")
- .name("b")
- .value("c")
- .build();
-
- HasQuery a2 = HasQueryAnnotation.create()
- .description("a")
- .name("b")
- .value("c")
- .build();
-
- @Test void a01_basic() {
- assertBean(a1, "description,name,value", "[a],b,c");
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HeaderAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HeaderAnnotation_Test.java
deleted file mode 100644
index 2d7cf38aa4..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/HeaderAnnotation_Test.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.oapi.*;
-import org.junit.jupiter.api.*;
-
-@SuppressWarnings({
- "java:S1186" // Empty test method intentional for framework testing
-})
-class HeaderAnnotation_Test extends TestBase {
-
- private static final String CNAME = HeaderAnnotation_Test.class.getName();
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- Header a1 = HeaderAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- Header a2 = HeaderAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- @Test void a01_basic() {
- assertBean(
- a1,
- "def,description,name,on,onClass{#{simpleName}},parser{simpleName},serializer{simpleName},value",
- "a,[b],c,[d],{[{X1}]},{OpenApiParser},{OpenApiSerializer},e"
- );
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() throws Exception {
- var c1 = HeaderAnnotation.create(C1.class).on(C2.class).build();
- var c2 = HeaderAnnotation.create("a").on("b").build();
- var c3 = HeaderAnnotation.create().on(C1.class.getField("f1")).on(C2.class.getField("f2")).build();
- var c4 = HeaderAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- assertBean(c3, "on", "["+CNAME+"$C1.f1,"+CNAME+"$C2.f2]");
- assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Comparison with declared annotations.
- //------------------------------------------------------------------------------------------------------------------
-
- @Header(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D1 {}
- Header d1 = D1.class.getAnnotationsByType(Header.class)[0];
-
- @Header(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D2 {}
- Header d2 = D2.class.getAnnotationsByType(Header.class)[0];
-
- @Test void d01_comparisonWithDeclarativeAnnotations() {
- assertEqualsAll(a1, d1, d2);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/PathAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/PathAnnotation_Test.java
deleted file mode 100644
index 721c4fed90..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/PathAnnotation_Test.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.oapi.*;
-import org.junit.jupiter.api.*;
-
-@SuppressWarnings({
- "java:S1186" // Empty test method intentional for framework testing
-})
-class PathAnnotation_Test extends TestBase {
-
- private static final String CNAME = PathAnnotation_Test.class.getName();
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- Path a1 = PathAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- Path a2 = PathAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- @Test void a01_basic() {
- assertBean(
- a1,
- "def,description,name,on,onClass{#{simpleName}},parser{simpleName},serializer{simpleName},value",
- "a,[b],c,[d],{[{X1}]},{OpenApiParser},{OpenApiSerializer},e"
- );
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() throws Exception {
- var c1 = PathAnnotation.create(C1.class).on(C2.class).build();
- var c2 = PathAnnotation.create("a").on("b").build();
- var c3 = PathAnnotation.create().on(C1.class.getField("f1")).on(C2.class.getField("f2")).build();
- var c4 = PathAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- assertBean(c3, "on", "["+CNAME+"$C1.f1,"+CNAME+"$C2.f2]");
- assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Comparison with declared annotations.
- //------------------------------------------------------------------------------------------------------------------
-
- @Path(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D1 {}
- Path d1 = D1.class.getAnnotationsByType(Path.class)[0];
-
- @Path(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D2 {}
- Path d2 = D2.class.getAnnotationsByType(Path.class)[0];
-
- @Test void d01_comparisonWithDeclarativeAnnotations() {
- assertEqualsAll(a1, d1, d2);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/QueryAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/QueryAnnotation_Test.java
deleted file mode 100644
index b58bb2859c..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/QueryAnnotation_Test.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.oapi.*;
-import org.junit.jupiter.api.*;
-
-@SuppressWarnings({
- "java:S1186" // Empty test method intentional for framework testing
-})
-class QueryAnnotation_Test extends TestBase {
-
- private static final String CNAME = QueryAnnotation_Test.class.getName();
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- Query a1 = QueryAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- Query a2 = QueryAnnotation.create()
- .def("a")
- .description("b")
- .name("c")
- .on("d")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .value("e")
- .build();
-
- @Test void a01_basic() {
- assertBean(
- a1,
- "def,description,name,on,onClass{#{simpleName}},parser{simpleName},serializer{simpleName},value",
- "a,[b],c,[d],{[{X1}]},{OpenApiParser},{OpenApiSerializer},e"
- );
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() throws Exception {
- var c1 = QueryAnnotation.create(C1.class).on(C2.class).build();
- var c2 = QueryAnnotation.create("a").on("b").build();
- var c3 = QueryAnnotation.create().on(C1.class.getField("f1")).on(C2.class.getField("f2")).build();
- var c4 = QueryAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- assertBean(c3, "on", "["+CNAME+"$C1.f1,"+CNAME+"$C2.f2]");
- assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Comparison with declared annotations.
- //------------------------------------------------------------------------------------------------------------------
-
- @Query(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D1 {}
- Query d1 = D1.class.getAnnotationsByType(Query.class)[0];
-
- @Query(
- def="a",
- description={ "b" },
- name="c",
- on="d",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class,
- value="e"
- )
- public static class D2 {}
- Query d2 = D2.class.getAnnotationsByType(Query.class)[0];
-
- @Test void d01_comparisonWithDeclarativeAnnotations() {
- assertEqualsAll(a1, d1, d2);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/RequestAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/RequestAnnotation_Test.java
deleted file mode 100644
index e2b2209e13..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/RequestAnnotation_Test.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.oapi.*;
-import org.junit.jupiter.api.*;
-
-@SuppressWarnings({
- "java:S1186" // Empty test method intentional for framework testing
-})
-class RequestAnnotation_Test extends TestBase {
-
- private static final String CNAME = RequestAnnotation_Test.class.getName();
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- Request a1 = RequestAnnotation.create()
- .description("a")
- .on("b")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .build();
-
- Request a2 = RequestAnnotation.create()
- .description("a")
- .on("b")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
- .serializer(OpenApiSerializer.class)
- .build();
-
- @Test void a01_basic() {
- assertBean(a1, "description,on,onClass,parser,serializer", "[a],[b],[X1],OpenApiParser,OpenApiSerializer");
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() {
- var c1 = RequestAnnotation.create(C1.class).on(C2.class).build();
- var c2 = RequestAnnotation.create("a").on("b").build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Comparison with declared annotations.
- //------------------------------------------------------------------------------------------------------------------
-
- @Request(
- description={ "a" },
- on="b",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class
- )
- public static class D1 {}
- Request d1 = D1.class.getAnnotationsByType(Request.class)[0];
-
- @Request(
- description={ "a" },
- on="b",
- onClass=X1.class,
- parser=OpenApiParser.class,
- serializer=OpenApiSerializer.class
- )
- public static class D2 {}
- Request d2 = D2.class.getAnnotationsByType(Request.class)[0];
-
- @Test void d01_comparisonWithDeclarativeAnnotations() {
- assertEqualsAll(a1, d1, d2);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
index dab9da4db6..2358e80131 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseAnnotation_Test.java
@@ -22,7 +22,6 @@ import static org.junit.jupiter.api.Assertions.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
-import org.apache.juneau.oapi.*;
import org.junit.jupiter.api.*;
@SuppressWarnings({
@@ -30,10 +29,6 @@ import org.junit.jupiter.api.*;
})
class ResponseAnnotation_Test extends TestBase {
- private static final String CNAME = ResponseAnnotation_Test.class.getName();
-
- public static class X1 {}
-
//------------------------------------------------------------------------------------------------------------------
// Basic tests
//------------------------------------------------------------------------------------------------------------------
@@ -41,30 +36,22 @@ class ResponseAnnotation_Test extends TestBase {
Response a1 = ResponseAnnotation.create()
.description("a")
.examples("b")
- .headers(HeaderAnnotation.DEFAULT)
- .on("c")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
+ .headers()
.schema(SchemaAnnotation.DEFAULT)
- .serializer(OpenApiSerializer.class)
.build();
Response a2 = ResponseAnnotation.create()
.description("a")
.examples("b")
- .headers(HeaderAnnotation.DEFAULT)
- .on("c")
- .onClass(X1.class)
- .parser(OpenApiParser.class)
+ .headers()
.schema(SchemaAnnotation.DEFAULT)
- .serializer(OpenApiSerializer.class)
.build();
@Test void a01_basic() {
assertBean(
a1,
- "description,examples,on,onClass{#{simpleName}},parser{simpleName},serializer{simpleName}",
- "[a],[b],[c],{[{X1}]},{OpenApiParser},{OpenApiSerializer}"
+ "description,examples",
+ "[a],[b]"
);
}
@@ -84,29 +71,6 @@ class ResponseAnnotation_Test extends TestBase {
assertSame(bc1, bc2);
}
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() throws Exception {
- var c1 = ResponseAnnotation.create(C1.class).on(C2.class).build();
- var c2 = ResponseAnnotation.create("a").on("b").build();
- var c4 = ResponseAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
- }
-
//------------------------------------------------------------------------------------------------------------------
// Comparison with declared annotations.
//------------------------------------------------------------------------------------------------------------------
@@ -114,12 +78,7 @@ class ResponseAnnotation_Test extends TestBase {
@Response(
description={ "a" },
examples="b",
- headers=@Header,
- on="c",
- onClass=X1.class,
- parser=OpenApiParser.class,
- schema=@Schema,
- serializer=OpenApiSerializer.class
+ schema=@Schema
)
public static class D1 {}
Response d1 = D1.class.getAnnotationsByType(Response.class)[0];
@@ -127,12 +86,7 @@ class ResponseAnnotation_Test extends TestBase {
@Response(
description={ "a" },
examples="b",
- headers=@Header,
- on="c",
- onClass=X1.class,
- parser=OpenApiParser.class,
- schema=@Schema,
- serializer=OpenApiSerializer.class
+ schema=@Schema
)
public static class D2 {}
Response d2 = D2.class.getAnnotationsByType(Response.class)[0];
@@ -142,4 +96,4 @@ class ResponseAnnotation_Test extends TestBase {
assertNotEqualsAny(a1.hashCode(), 0, -1);
assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
}
-}
\ No newline at end of file
+}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseStatusAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseStatusAnnotation_Test.java
deleted file mode 100644
index 5603094e78..0000000000
--- a/juneau-utest/src/test/java/org/apache/juneau/http/annotation/ResponseStatusAnnotation_Test.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.juneau.http.annotation;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.apache.juneau.junit.bct.BctAssertions.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-import org.apache.juneau.*;
-import org.junit.jupiter.api.*;
-
-@SuppressWarnings({
- "java:S1186" // Empty test method intentional for framework testing
-})
-class ResponseStatusAnnotation_Test extends TestBase {
-
- private static final String CNAME = ResponseStatusAnnotation_Test.class.getName();
-
- public static class X1 {}
-
- //------------------------------------------------------------------------------------------------------------------
- // Basic tests
- //------------------------------------------------------------------------------------------------------------------
-
- StatusCode a1 = StatusCodeAnnotation.create()
- .description("a")
- .on("b")
- .onClass(X1.class)
- .value(1)
- .build();
-
- StatusCode a2 = StatusCodeAnnotation.create()
- .description("a")
- .on("b")
- .onClass(X1.class)
- .value(1)
- .build();
-
- @Test void a01_basic() {
- assertBean(a1, "description,on,onClass,value", "[a],[b],[X1],[1]");
- }
-
- @Test void a02_testEquivalency() {
- assertEquals(a2, a1);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEquals(a1.hashCode(), a2.hashCode());
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // PropertyStore equivalency.
- //------------------------------------------------------------------------------------------------------------------
-
- @Test void b01_testEquivalencyInPropertyStores() {
- var bc1 = BeanContext.create().annotations(a1).build();
- var bc2 = BeanContext.create().annotations(a2).build();
- assertSame(bc1, bc2);
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Other methods.
- //------------------------------------------------------------------------------------------------------------------
-
- public static class C1 {
- public int f1;
- public void m1() {}
- }
- public static class C2 {
- public int f2;
- public void m2() {}
- }
-
- @Test void c01_otherMethods() throws Exception {
- var c1 = StatusCodeAnnotation.create(C1.class).on(C2.class).build();
- var c2 = StatusCodeAnnotation.create("a").on("b").build();
- var c4 = StatusCodeAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
-
- assertBean(c1, "on", "["+CNAME+"$C1,"+CNAME+"$C2]");
- assertBean(c2, "on", "[a,b]");
- assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
- }
-
- //------------------------------------------------------------------------------------------------------------------
- // Comparison with declared annotations.
- //------------------------------------------------------------------------------------------------------------------
-
- @StatusCode(
- description={ "a" },
- on="b",
- onClass=X1.class,
- value=1
- )
- public static class D1 {}
- StatusCode d1 = D1.class.getAnnotationsByType(StatusCode.class)[0];
-
- @StatusCode(
- description={ "a" },
- on="b",
- onClass=X1.class,
- value=1
- )
- public static class D2 {}
- StatusCode d2 = D2.class.getAnnotationsByType(StatusCode.class)[0];
-
- @Test void d01_comparisonWithDeclarativeAnnotations() {
- assertEqualsAll(a1, d1, d2);
- assertNotEqualsAny(a1.hashCode(), 0, -1);
- assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
- }
-}
\ No newline at end of file
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java
index 1e4f519142..3ce85e58b7 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_FormDataAnnotation_Test.java
@@ -39,7 +39,6 @@ import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.mock.*;
import org.apache.juneau.uon.*;
import org.apache.juneau.urlencoding.*;
-import org.apache.juneau.utest.utils.*;
import org.junit.jupiter.api.*;
@SuppressWarnings({
@@ -694,12 +693,12 @@ class Remote_FormDataAnnotation_Test extends TestBase {
@Remote
public interface J1 {
- @RemoteOp(path="/") String postX1(@FormData(name="x",serializer=FakeWriterSerializer.X.class) String b);
+ @RemoteOp(path="/") String postX1(@FormData(name="x") String b);
}
@Test void j01_serializer() {
var x = remote(J.class,J1.class);
- assertEquals("{x:'xXx'}",x.postX1("X"));
+ assertEquals("{x:'X'}",x.postX1("X"));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -721,7 +720,7 @@ class Remote_FormDataAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K1 {
@RemoteOp(path="/") String postX1(@Request K1a rb);
- @RemoteOp(path="/") String postX2(@Request(serializer=FakeWriterSerializer.X.class) K1a rb);
+ @RemoteOp(path="/") String postX2(@Request K1a rb);
}
public static class K1a {
@@ -742,7 +741,7 @@ class Remote_FormDataAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K1.class);
assertEquals("{a=a1,b=b1,c=c1,e=,g=true,h=123,i1=foo}",x1.postX1(new K1a()));
assertEquals("{a=a1,b=b1,c=c1,e=,g='true',h='123',i1=foo}",x2.postX1(new K1a()));
- assertEquals("{a=xa1x,b=xb1x,c=xc1x,e=xx,g=xtruex,h=x123x,i1=xfoox}",x2.postX2(new K1a()));
+ assertEquals("{a=a1,b=b1,c=c1,e=,g='true',h='123',i1=foo}",x2.postX2(new K1a()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -752,7 +751,7 @@ class Remote_FormDataAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K2 {
@RemoteOp(path="/") String postX1(@Request K2a rb);
- @RemoteOp(path="/") String postX2(@Request(serializer=FakeWriterSerializer.X.class) K2a rb);
+ @RemoteOp(path="/") String postX2(@Request K2a rb);
}
public static class K2a {
@@ -767,7 +766,7 @@ class Remote_FormDataAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K2.class);
assertEquals("{a=a1=v1,a2=123,a3=null,a4=,b1=true,b2=123,b3=null,c1=v1,c2=123,c4=}",x1.postX1(new K2a()));
assertEquals("{a=(a1=v1,a2=123,a3=null,a4=''),b1='true',b2='123',b3='null',c1=v1,c2=123,c4=}",x2.postX1(new K2a()));
- assertEquals("{a=x{a1=v1, a2=123, a3=null, a4=}x,b1=xtruex,b2=x123x,b3=xnullx,c1=xv1x,c2=x123x,c4=xx}",x2.postX2(new K2a()));
+ assertEquals("{a=(a1=v1,a2=123,a3=null,a4=''),b1='true',b2='123',b3='null',c1=v1,c2=123,c4=}",x2.postX2(new K2a()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -777,7 +776,7 @@ class Remote_FormDataAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K3 {
@RemoteOp(path="/") String postX1(@Request K3a rb);
- @RemoteOp(path="/") String postX2(@Request(serializer=FakeWriterSerializer.X.class) K3a rb);
+ @RemoteOp(path="/") String postX2(@Request K3a rb);
}
public static class K3a {
@@ -839,17 +838,17 @@ class Remote_FormDataAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K6 {
@RemoteOp(path="/") String postX1(@Request K6a rb);
- @RemoteOp(path="/") String postX2(@Request(serializer=FakeWriterSerializer.X.class) K6a rb);
+ @RemoteOp(path="/") String postX2(@Request K6a rb);
}
public static class K6a {
@FormData public List<Object> getA() { return l("foo","","true","123","null",true,123,null); }
@FormData("b") public List<Object> getX1() { return l("foo","","true","123","null",true,123,null); }
- @FormData(name="c",serializer=FakeWriterSerializer.X.class) public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
+ @FormData(name="c") public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
@FormData("d") @Schema(aev=true) public List<Object> getX3() { return l(); }
@FormData("e") public List<Object> getX4() { return null; }
@FormData("f") public Object[] getX5() { return a("foo","","true","123","null",true,123,null); }
- @FormData(name="g",serializer=FakeWriterSerializer.X.class) public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
+ @FormData(name="g") public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
@FormData("h") @Schema(aev=true) public Object[] getX7() { return a(); }
@FormData("i") public Object[] getX8() { return null; }
}
@@ -857,9 +856,9 @@ class Remote_FormDataAnnotation_Test extends TestBase {
@Test void k06_requestBean_collections() {
var x1 = remote(K.class,K6.class);
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K6.class);
- assertEquals("{a=foo,,true,123,null,true,123,null,b=foo,,true,123,null,true,123,null,c=xfoo||true|123|null|true|123|nullx,d=,f=foo,,true,123,null,true,123,null,g=xfoo||true|123|null|true|123|nullx,h=}", x1.postX1(new K6a()));
- assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=xfoo||true|123|null|true|123|nullx,d=@(),f=@(foo,'','true','123','null',true,123,null),g=xfoo||true|123|null|true|123|nullx,h=@()}", x2.postX1(new K6a()));
- assertEquals("{a=xfoo||true|123|null|true|123|nullx,b=xfoo||true|123|null|true|123|nullx,c=xfoo||true|123|null|true|123|nullx,d=xx,f=xfoo||true|123|null|true|123|nullx,g=xfoo||true|123|null|true|123|nullx,h=xx}", x2.postX2(new K6a()));
+ assertEquals("{a=foo,,true,123,null,true,123,null,b=foo,,true,123,null,true,123,null,c=foo,,true,123,null,true,123,null,d=,f=foo,,true,123,null,true,123,null,g=foo,,true,123,null,true,123,null,h=}", x1.postX1(new K6a()));
+ assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=@(foo,'','true','123','null',true,123,null),d=@(),f=@(foo,'','true','123','null',true,123,null),g=@(foo,'','true','123','null',true,123,null),h=@()}", x2.postX1(new K6a()));
+ assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=@(foo,'','true','123','null',true,123,null),d=@(),f=@(foo,'','true','123','null',true,123,null),g=@(foo,'','true','123','null',true,123,null),h=@()}", x2.postX2(new K6a()));
}
//------------------------------------------------------------------------------------------------------------------
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java
index 6d8b20a759..490a417b82 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_HeaderAnnotation_Test.java
@@ -35,7 +35,6 @@ import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.mock.*;
import org.apache.juneau.uon.*;
-import org.apache.juneau.utest.utils.*;
import org.junit.jupiter.api.*;
@SuppressWarnings({
@@ -657,12 +656,12 @@ class Remote_HeaderAnnotation_Test extends TestBase {
@Remote
public interface J1 {
- @RemoteOp(path="/") String getX1(@Header(name="x",serializer=FakeWriterSerializer.X.class) String b);
+ @RemoteOp(path="/") String getX1(@Header(name="x") String b);
}
@Test void j01_serializer() {
var x = remote(J.class,J1.class);
- assertEquals("{x:'xXx'}",x.getX1("X"));
+ assertEquals("{x:'X'}",x.getX1("X"));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -684,7 +683,7 @@ class Remote_HeaderAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K1 {
@RemoteOp(path="/") String getX1(@Request K1a rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K1a rb);
+ @RemoteOp(path="/") String getX2(@Request K1a rb);
}
public static class K1a {
@@ -705,7 +704,7 @@ class Remote_HeaderAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K1.class);
assertEquals("{a=a1,b=b1,c=c1,e=,g=true,h=123,i1=foo}",x1.getX1(new K1a()));
assertEquals("{a=a1,b=b1,c=c1,e=,g='true',h='123',i1=foo}",x2.getX1(new K1a()));
- assertEquals("{a=xa1x,b=xb1x,c=xc1x,e=xx,g=xtruex,h=x123x,i1=xfoox}",x2.getX2(new K1a()));
+ assertEquals("{a=a1,b=b1,c=c1,e=,g='true',h='123',i1=foo}",x2.getX2(new K1a()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -715,7 +714,7 @@ class Remote_HeaderAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K2 {
@RemoteOp(path="/") String getX1(@Request K2a rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K2a rb);
+ @RemoteOp(path="/") String getX2(@Request K2a rb);
}
public static class K2a {
@@ -730,7 +729,7 @@ class Remote_HeaderAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K2.class);
assertEquals("{a=a1=v1,a2=123,a3=null,a4=,b1=true,b2=123,b3=null,c1=v1,c2=123,c4=}",x1.getX1(new K2a()));
assertEquals("{a=(a1=v1,a2=123,a3=null,a4=''),b1='true',b2='123',b3='null',c1=v1,c2=123,c4=}",x2.getX1(new K2a()));
- assertEquals("{a=x{a1=v1, a2=123, a3=null, a4=}x,b1=xtruex,b2=x123x,b3=xnullx,c1=xv1x,c2=x123x,c4=xx}",x2.getX2(new K2a()));
+ assertEquals("{a=(a1=v1,a2=123,a3=null,a4=''),b1='true',b2='123',b3='null',c1=v1,c2=123,c4=}",x2.getX2(new K2a()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -740,7 +739,7 @@ class Remote_HeaderAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K3 {
@RemoteOp(path="/") String getX1(@Request K3a rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K3a rb);
+ @RemoteOp(path="/") String getX2(@Request K3a rb);
}
public static class K3a {
@@ -767,17 +766,17 @@ class Remote_HeaderAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K4 {
@RemoteOp(path="/") String getX1(@Request K4a rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K4a rb);
+ @RemoteOp(path="/") String getX2(@Request K4a rb);
}
public static class K4a {
@Header public List<Object> getA() { return l("foo","","true","123","null",true,123,null); }
@Header("b") public List<Object> getX1() { return l("foo","","true","123","null",true,123,null); }
- @Header(name="c",serializer=FakeWriterSerializer.X.class) public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
+ @Header(name="c") public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
@Header(name="d") @Schema(aev=true) public List<Object> getX3() { return l(); }
@Header("e") public List<Object> getX4() { return null; }
@Header("f") public Object[] getX5() { return a("foo","","true","123","null",true,123,null); }
- @Header(name="g",serializer=FakeWriterSerializer.X.class) public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
+ @Header(name="g") public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
@Header(name="h") @Schema(aev=true) public Object[] getX7() { return a(); }
@Header("i") public Object[] getX8() { return null; }
}
@@ -785,9 +784,9 @@ class Remote_HeaderAnnotation_Test extends TestBase {
@Test void k04_requestBean_collections() {
var x1 = remote(K.class,K4.class);
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K4.class);
- assertEquals("{a=foo,,true,123,null,true,123,null,b=foo,,true,123,null,true,123,null,c=xfoo||true|123|null|true|123|nullx,d=,f=foo,,true,123,null,true,123,null,g=xfoo||true|123|null|true|123|nullx,h=}", x1.getX1(new K4a()));
- assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=xfoo||true|123|null|true|123|nullx,d=@(),f=@(foo,'','true','123','null',true,123,null),g=xfoo||true|123|null|true|123|nullx,h=@()}", x2.getX1(new K4a()));
- assertEquals("{a=xfoo||true|123|null|true|123|nullx,b=xfoo||true|123|null|true|123|nullx,c=xfoo||true|123|null|true|123|nullx,d=xx,f=xfoo||true|123|null|true|123|nullx,g=xfoo||true|123|null|true|123|nullx,h=xx}", x2.getX2(new K4a()));
+ assertEquals("{a=foo,,true,123,null,true,123,null,b=foo,,true,123,null,true,123,null,c=foo,,true,123,null,true,123,null,d=,f=foo,,true,123,null,true,123,null,g=foo,,true,123,null,true,123,null,h=}", x1.getX1(new K4a()));
+ assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=@(foo,'','true','123','null',true,123,null),d=@(),f=@(foo,'','true','123','null',true,123,null),g=@(foo,'','true','123','null',true,123,null),h=@()}", x2.getX1(new K4a()));
+ assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=@(foo,'','true','123','null',true,123,null),d=@(),f=@(foo,'','true','123','null',true,123,null),g=@(foo,'','true','123','null',true,123,null),h=@()}", x2.getX2(new K4a()));
}
//------------------------------------------------------------------------------------------------------------------
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_MethodDefaultsAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_MethodDefaultsAnnotation_Test.java
index fc88acd683..05a6e719ab 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_MethodDefaultsAnnotation_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_MethodDefaultsAnnotation_Test.java
@@ -68,23 +68,6 @@ class Remote_MethodDefaultsAnnotation_Test {
assertEquals("Foo=defaultFoo,Bar=null", x.x1(null, null));
}
- @Remote
- public interface A2 {
- @RemoteGet("/x1")
- @Header(name="Foo", def="defaultFoo")
- @Header(name="Bar", def="defaultBar")
- String x1(@Header("Foo") String foo, @Header("Bar") String bar);
- }
-
- @Test
- void a04_headerDefaults_multipleDefaults() {
- var x = MockRestClient.buildJson5(A.class).getRemote(A2.class);
- assertEquals("Foo=defaultFoo,Bar=defaultBar", x.x1(null, null));
- assertEquals("Foo=customFoo,Bar=defaultBar", x.x1("customFoo", null));
- assertEquals("Foo=defaultFoo,Bar=customBar", x.x1(null, "customBar"));
- assertEquals("Foo=customFoo,Bar=customBar", x.x1("customFoo", "customBar"));
- }
-
//-----------------------------------------------------------------------------------------------------------------
// @Query defaults on methods
//-----------------------------------------------------------------------------------------------------------------
@@ -116,22 +99,6 @@ class Remote_MethodDefaultsAnnotation_Test {
assertEquals("foo=defaultFoo,bar=customBar", x.x1(null, "customBar"));
}
- @Remote
- public interface B2 {
- @RemoteGet("/x1")
- @Query(name="foo", def="defaultFoo")
- @Query(name="bar", def="defaultBar")
- String x1(@Query("foo") String foo, @Query("bar") String bar);
- }
-
- @Test
- void b03_queryDefaults_multipleDefaults() {
- var x = MockRestClient.buildJson5(B.class).getRemote(B2.class);
- assertEquals("foo=defaultFoo,bar=defaultBar", x.x1(null, null));
- assertEquals("foo=customFoo,bar=defaultBar", x.x1("customFoo", null));
- assertEquals("foo=defaultFoo,bar=customBar", x.x1(null, "customBar"));
- }
-
//-----------------------------------------------------------------------------------------------------------------
// @FormData defaults on methods
//-----------------------------------------------------------------------------------------------------------------
@@ -163,21 +130,6 @@ class Remote_MethodDefaultsAnnotation_Test {
assertEquals("foo=defaultFoo,bar=customBar", x.x1(null, "customBar"));
}
- @Remote
- public interface C2 {
- @RemotePost("/x1")
- @FormData(name="foo", def="defaultFoo")
- @FormData(name="bar", def="defaultBar")
- String x1(@FormData("foo") String foo, @FormData("bar") String bar);
- }
-
- @Test
- void c03_formDataDefaults_multipleDefaults() {
- var x = MockRestClient.buildJson5(C.class).getRemote(C2.class);
- assertEquals("foo=defaultFoo,bar=defaultBar", x.x1(null, null));
- assertEquals("foo=customFoo,bar=defaultBar", x.x1("customFoo", null));
- }
-
//-----------------------------------------------------------------------------------------------------------------
// @Path defaults on methods
// NOTE: Path variables with nulls cause validation errors, so we test with actual provided values only
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java
index d4aae31515..a4d00428f3 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_PathAnnotation_Test.java
@@ -37,7 +37,6 @@ import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.mock.*;
import org.apache.juneau.uon.*;
-import org.apache.juneau.utest.utils.*;
import org.junit.jupiter.api.*;
@SuppressWarnings({
@@ -85,7 +84,7 @@ class Remote_PathAnnotation_Test extends TestBase {
@RemoteOp(path="a/{x}") String getX14(@Path @Schema(f="uon") Map<String,Bean> b);
@RemoteOp(path="a/{x}") String getX15(@Path("*") PartList b);
@RemoteOp(path="a/{x}") String getX16(@Path PartList b);
- @RemoteOp(path="a/{x}") String getX17(@Path(name="x",serializer=UonSerializer.class) Map<String,Bean> b);
+ @RemoteOp(path="a/{x}") String getX17(@Path(name="x") @Schema(f="uon") Map<String,Bean> b);
@RemoteOp(path="a/{x}") String getX18(@Path("*") NameValuePair b);
@RemoteOp(path="a/{x}") String getX19(@Path NameValuePair b);
@RemoteOp(path="a/{x}") String getX20(@Path NameValuePair[] b);
@@ -111,7 +110,7 @@ class Remote_PathAnnotation_Test extends TestBase {
assertEquals("x=1",x.getX14(map("x",Bean.create())));
assertEquals("bar",x.getX15(parts("x","bar")));
assertEquals("bar",x.getX16(parts("x","bar")));
- assertEquals("(x=(x=1))",x.getX17(map("x",Bean.create())));
+ assertEquals("x=x\\=1",x.getX17(map("x",Bean.create())));
assertEquals("bar",x.getX18(part("x","bar")));
assertEquals("bar",x.getX19(part("x","bar")));
assertEquals("bar",x.getX20(a(part("x","bar"))));
@@ -570,12 +569,12 @@ class Remote_PathAnnotation_Test extends TestBase {
@Remote
public interface H1 {
- @RemoteOp(path="/{x}") String getX1(@Path(name="x",serializer=FakeWriterSerializer.X.class) String b);
+ @RemoteOp(path="/{x}") String getX1(@Path(name="x") String b);
}
@Test void h01_path_serializer() {
var x = remote(H.class,H1.class);
- assertEquals("{x:'xXx'}",x.getX1("X"));
+ assertEquals("{x:'X'}",x.getX1("X"));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -597,7 +596,7 @@ class Remote_PathAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K1 {
@RemoteOp(path="/{a}/{b}/{c}/{e}/{g}/{h}") String getX1(@Request K1a rb);
- @RemoteOp(path="/{a}/{b}/{c}/{e}/{g}/{h}") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K1a rb);
+ @RemoteOp(path="/{a}/{b}/{c}/{e}/{g}/{h}") String getX2(@Request K1a rb);
}
public static class K1a {
@@ -614,7 +613,7 @@ class Remote_PathAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K1.class);
assertEquals("a1/b1/c1//true/123",x1.getX1(new K1a()));
assertEquals("a1/b1/c1//'true'/'123'",x2.getX1(new K1a()));
- assertEquals("xa1x/xb1x/xc1x/xx/xtruex/x123x",x2.getX2(new K1a()));
+ assertEquals("a1/b1/c1//'true'/'123'",x2.getX2(new K1a()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -624,7 +623,7 @@ class Remote_PathAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K2 {
@RemoteOp(path="/{a1}/{a2}/{a3}/{a4}/{b1}/{b2}/{b3}/{c1}/{c2}/{c3}/{c4}") String getX1(@Request K2a rb);
- @RemoteOp(path="/{a1}/{a2}/{a3}/{a4}/{b1}/{b2}/{b3}/{c1}/{c2}/{c3}/{c4}") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K2a rb);
+ @RemoteOp(path="/{a1}/{a2}/{a3}/{a4}/{b1}/{b2}/{b3}/{c1}/{c2}/{c3}/{c4}") String getX2(@Request K2a rb);
}
public static class K2a {
@@ -640,7 +639,7 @@ class Remote_PathAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K2.class);
assertEquals("v1/123/null//true/123/null/v1/123/null/",x1.getX1(new K2a()));
assertEquals("v1/123/null//'true'/'123'/'null'/v1/123/null/",x2.getX1(new K2a()));
- assertEquals("xv1x/x123x/null/xx/xtruex/x123x/xnullx/xv1x/x123x/null/xx",x2.getX2(new K2a()));
+ assertEquals("v1/123/null//'true'/'123'/'null'/v1/123/null/",x2.getX2(new K2a()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -650,7 +649,7 @@ class Remote_PathAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K3 {
@RemoteOp(path="/{a1}/{a2}/{a3}/{a4}/{b1}/{b2}/{b3}/{c1}/{c2}/{c3}/{c4}/{e1}/{e2}/{e3}/{e4}") String getX1(@Request K3a rb);
- @RemoteOp(path="/{a1}/{a2}/{a3}/{a4}/{b1}/{b2}/{b3}/{c1}/{c2}/{c3}/{c4}/{e1}/{e2}/{e3}/{e4}") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K3a rb);
+ @RemoteOp(path="/{a1}/{a2}/{a3}/{a4}/{b1}/{b2}/{b3}/{c1}/{c2}/{c3}/{c4}/{e1}/{e2}/{e3}/{e4}") String getX2(@Request K3a rb);
}
public static class K3a {
@@ -677,16 +676,16 @@ class Remote_PathAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K4 {
@RemoteOp(path="/{a}/{b}/{c}/{d}/{f}/{g}/{h}") String getX1(@Request K4a rb);
- @RemoteOp(path="/{a}/{b}/{c}/{d}/{f}/{g}/{h}") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K4a rb);
+ @RemoteOp(path="/{a}/{b}/{c}/{d}/{f}/{g}/{h}") String getX2(@Request K4a rb);
}
public static class K4a {
@Path public List<Object> getA() { return l("foo","","true","123","null",true,123,null); }
@Path("b") public List<Object> getX1() { return l("foo","","true","123","null",true,123,null); }
- @Path(name="c",serializer=FakeWriterSerializer.X.class) public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
+ @Path(name="c") public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
@Path("d") @Schema(aev=true) public List<Object> getX3() { return l(); }
@Path("f") public Object[] getX5() { return a("foo","","true","123","null",true,123,null); }
- @Path(name="g",serializer=FakeWriterSerializer.X.class) public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
+ @Path(name="g") public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
@Path("h") @Schema(aev=true)
public Object[] getX7() { return a(); }
}
@@ -694,9 +693,9 @@ class Remote_PathAnnotation_Test extends TestBase {
@Test void k04_requestBean_collections() {
var x1 = remote(K.class,K4.class);
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K4.class);
- assertEquals("foo,,true,123,null,true,123,null/foo,,true,123,null,true,123,null/xfoo||true|123|null|true|123|nullx//foo,,true,123,null,true,123,null/xfoo||true|123|null|true|123|nullx/", x1.getX1(new K4a()));
- assertEquals("@(foo,'','true','123','null',true,123,null)/@(foo,'','true','123','null',true,123,null)/xfoo||true|123|null|true|123|nullx/@()/@(foo,'','true','123','null',true,123,null)/xfoo||true|123|null|true|123|nullx/@()", x2.getX1(new K4a()));
- assertEquals("xfoo||true|123|null|true|123|nullx/xfoo||true|123|null|true|123|nullx/xfoo||true|123|null|true|123|nullx/xx/xfoo||true|123|null|true|123|nullx/xfoo||true|123|null|true|123|nullx/xx", x2.getX2(new K4a()));
+ assertEquals("foo,,true,123,null,true,123,null/foo,,true,123,null,true,123,null/foo,,true,123,null,true,123,null//foo,,true,123,null,true,123,null/foo,,true,123,null,true,123,null/", x1.getX1(new K4a()));
+ assertEquals("@(foo,'','true','123','null',true,123,null)/@(foo,'','true','123','null',true,123,null)/@(foo,'','true','123','null',true,123,null)/@()/@(foo,'','true','123','null',true,123,null)/@(foo,'','true','123','null',true,123,null)/@()", x2.getX1(new K4a()));
+ assertEquals("@(foo,'','true','123','null',true,123,null)/@(foo,'','true','123','null',true,123,null)/@(foo,'','true','123','null',true,123,null)/@()/@(foo,'','true','123','null',true,123,null)/@(foo,'','true','123','null',true,123,null)/@()", x2.getX2(new K4a()));
}
//------------------------------------------------------------------------------------------------------------------
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java
index a3041face3..bb802f2a83 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_QueryAnnotation_Test.java
@@ -37,7 +37,6 @@ import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.client.*;
import org.apache.juneau.rest.mock.*;
import org.apache.juneau.uon.*;
-import org.apache.juneau.utest.utils.*;
import org.junit.jupiter.api.*;
@SuppressWarnings({
@@ -675,12 +674,12 @@ class Remote_QueryAnnotation_Test extends TestBase {
@Remote
public interface J1 {
- @RemoteOp(path="/") String getX1(@Query(name="x",serializer=FakeWriterSerializer.X.class) String b);
+ @RemoteOp(path="/") String getX1(@Query(name="x") String b);
}
@Test void j01_serializer() {
var x = remote(J.class,J1.class);
- assertEquals("{x:'xXx'}",x.getX1("X"));
+ assertEquals("{x:'X'}",x.getX1("X"));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -702,7 +701,7 @@ class Remote_QueryAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K1 {
@RemoteOp(path="/") String getX1(@Request K1b rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K1b rb);
+ @RemoteOp(path="/") String getX2(@Request K1b rb);
}
public interface K1a {
@@ -736,7 +735,7 @@ class Remote_QueryAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K1.class);
assertEquals("{a=a1,b=b1,c=c1,e=,g=true,h=123,i1=foo}",x1.getX1(new K1b()));
assertEquals("{a=a1,b=b1,c=c1,e=,g='true',h='123',i1=foo}",x2.getX1(new K1b()));
- assertEquals("{a=xa1x,b=xb1x,c=xc1x,e=xx,g=xtruex,h=x123x,i1=xfoox}",x2.getX2(new K1b()));
+ assertEquals("{a=a1,b=b1,c=c1,e=,g='true',h='123',i1=foo}",x2.getX2(new K1b()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -746,7 +745,7 @@ class Remote_QueryAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K2 {
@RemoteOp(path="/") String getX1(@Request K2a rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K2a rb);
+ @RemoteOp(path="/") String getX2(@Request K2a rb);
}
public static class K2a {
@@ -762,7 +761,7 @@ class Remote_QueryAnnotation_Test extends TestBase {
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K2.class);
assertEquals("{a=a1=v1,a2=123,a3=null,a4=,b1=true,b2=123,b3=null,c1=v1,c2=123,c4=}",x1.getX1(new K2a()));
assertEquals("{a=(a1=v1,a2=123,a3=null,a4=''),b1='true',b2='123',b3='null',c1=v1,c2=123,c4=}",x2.getX1(new K2a()));
- assertEquals("{a=x{a1=v1, a2=123, a3=null, a4=}x,b1=xtruex,b2=x123x,b3=xnullx,c1=xv1x,c2=x123x,c4=xx}",x2.getX2(new K2a()));
+ assertEquals("{a=(a1=v1,a2=123,a3=null,a4=''),b1='true',b2='123',b3='null',c1=v1,c2=123,c4=}",x2.getX2(new K2a()));
}
//-----------------------------------------------------------------------------------------------------------------
@@ -772,7 +771,7 @@ class Remote_QueryAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K3 {
@RemoteOp(path="/") String getX1(@Request K3a rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K3a rb);
+ @RemoteOp(path="/") String getX2(@Request K3a rb);
}
public static class K3a {
@@ -834,17 +833,17 @@ class Remote_QueryAnnotation_Test extends TestBase {
@Remote(path="/")
public interface K6 {
@RemoteOp(path="/") String getX1(@Request K6a rb);
- @RemoteOp(path="/") String getX2(@Request(serializer=FakeWriterSerializer.X.class) K6a rb);
+ @RemoteOp(path="/") String getX2(@Request K6a rb);
}
public static class K6a {
@Query public List<Object> getA() { return l("foo","","true","123","null",true,123,null); }
@Query("b") public List<Object> getX1() { return l("foo","","true","123","null",true,123,null); }
- @Query(name="c",serializer=FakeWriterSerializer.X.class) public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
+ @Query(name="c") public List<Object> getX2() { return l("foo","","true","123","null",true,123,null); }
@Query("d") @Schema(allowEmptyValue=true) public List<Object> getX3() { return l(); }
@Query("e") public List<Object> getX4() { return null; }
@Query("f") public Object[] getX5() { return a("foo","","true","123","null",true,123,null); }
- @Query(name="g",serializer=FakeWriterSerializer.X.class) public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
+ @Query(name="g") public Object[] getX6() { return a("foo","","true","123","null",true,123,null); }
@Query("h") @Schema(allowEmptyValue=true) public Object[] getX7() { return a(); }
@Query("i") public Object[] getX8() { return null; }
}
@@ -852,9 +851,9 @@ class Remote_QueryAnnotation_Test extends TestBase {
@Test void k06_requestBean_collections() {
var x1 = remote(K.class,K6.class);
var x2 = client(K.class).partSerializer(UonSerializer.class).build().getRemote(K6.class);
- assertEquals("{a=foo,,true,123,null,true,123,null,b=foo,,true,123,null,true,123,null,c=xfoo||true|123|null|true|123|nullx,d=,f=foo,,true,123,null,true,123,null,g=xfoo||true|123|null|true|123|nullx,h=}", x1.getX1(new K6a()));
- assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=xfoo||true|123|null|true|123|nullx,d=@(),f=@(foo,'','true','123','null',true,123,null),g=xfoo||true|123|null|true|123|nullx,h=@()}", x2.getX1(new K6a()));
- assertEquals("{a=xfoo||true|123|null|true|123|nullx,b=xfoo||true|123|null|true|123|nullx,c=xfoo||true|123|null|true|123|nullx,d=xx,f=xfoo||true|123|null|true|123|nullx,g=xfoo||true|123|null|true|123|nullx,h=xx}", x2.getX2(new K6a()));
+ assertEquals("{a=foo,,true,123,null,true,123,null,b=foo,,true,123,null,true,123,null,c=foo,,true,123,null,true,123,null,d=,f=foo,,true,123,null,true,123,null,g=foo,,true,123,null,true,123,null,h=}", x1.getX1(new K6a()));
+ assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=@(foo,'','true','123','null',true,123,null),d=@(),f=@(foo,'','true','123','null',true,123,null),g=@(foo,'','true','123','null',true,123,null),h=@()}", x2.getX1(new K6a()));
+ assertEquals("{a=@(foo,'','true','123','null',true,123,null),b=@(foo,'','true','123','null',true,123,null),c=@(foo,'','true','123','null',true,123,null),d=@(),f=@(foo,'','true','123','null',true,123,null),g=@(foo,'','true','123','null',true,123,null),h=@()}", x2.getX2(new K6a()));
}
//------------------------------------------------------------------------------------------------------------------
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_RequestAnnotation_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_RequestAnnotation_Test.java
index 382e67fc6e..0734dca968 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_RequestAnnotation_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_RequestAnnotation_Test.java
@@ -26,7 +26,6 @@ import org.apache.juneau.collections.*;
import org.apache.juneau.http.annotation.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.mock.*;
-import org.apache.juneau.utest.utils.*;
import org.junit.jupiter.api.*;
class Remote_RequestAnnotation_Test extends TestBase {
@@ -253,7 +252,7 @@ class Remote_RequestAnnotation_Test extends TestBase {
}
}
- @Request(serializer=FakeWriterSerializer.X.class)
+ @Request
public static class E1 {
@Content
public String getBody() {
@@ -280,7 +279,7 @@ class Remote_RequestAnnotation_Test extends TestBase {
@Test void e01_partSerializer() {
var x = remote(E.class,E2.class);
- assertEquals("{body:'foo',header:'xxx',query:'xxx',path:'xxx'}",x.post(new E1()));
+ assertEquals("{body:'foo',header:'x',query:'x',path:'x'}",x.post(new E1()));
assertEquals("{body:'',header:null,query:null,path:'{x}'}",x.post(null));
}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/ng/rest/NgRemoteClient_Test.java b/juneau-utest/src/test/java/org/apache/juneau/ng/rest/NgRemoteClient_Test.java
index d6a4dae87e..b04f98679e 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/ng/rest/NgRemoteClient_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/ng/rest/NgRemoteClient_Test.java
@@ -21,6 +21,10 @@ import static org.junit.jupiter.api.Assertions.*;
import java.io.*;
import java.util.*;
+import org.apache.juneau.http.annotation.Content;
+import org.apache.juneau.http.annotation.Header;
+import org.apache.juneau.http.annotation.Path;
+import org.apache.juneau.http.annotation.Query;
import org.apache.juneau.http.remote.Remote;
import org.apache.juneau.http.remote.RemoteDelete;
import org.apache.juneau.http.remote.RemoteGet;
@@ -30,10 +34,6 @@ import org.apache.juneau.http.remote.RemotePut;
import org.apache.juneau.http.remote.RemoteReturn;
import org.apache.juneau.ng.http.HttpBody;
import org.apache.juneau.ng.http.entity.*;
-import org.apache.juneau.ng.http.remote.Body;
-import org.apache.juneau.ng.http.remote.Header;
-import org.apache.juneau.ng.http.remote.Path;
-import org.apache.juneau.ng.http.remote.Query;
import org.apache.juneau.ng.http.remote.RrpcInterfaceMeta;
import org.apache.juneau.ng.rest.client.*;
import org.apache.juneau.ng.rest.client.remote.*;
@@ -56,13 +56,13 @@ public class NgRemoteClient_Test {
String getUser(@Path("id") String id);
@RemotePost
- String createUser(@Body String json);
+ String createUser(@Content String json);
@RemotePut("/{id}")
- String updateUser(@Path("id") String id, @Body String json);
+ String updateUser(@Path("id") String id, @Content String json);
@RemotePatch("/{id}")
- String patchUser(@Path("id") String id, @Body String json);
+ String patchUser(@Path("id") String id, @Content String json);
@RemoteDelete("/{id}")
void deleteUser(@Path("id") String id);
@@ -137,7 +137,7 @@ public class NgRemoteClient_Test {
String listItems(@Query("page") String page);
@RemotePost
- String createItem(@Body String body);
+ String createItem(@Content String body);
@RemoteGet(returns = RemoteReturn.STATUS)
int getStatus();
@@ -294,13 +294,13 @@ public class NgRemoteClient_Test {
}
// ------------------------------------------------------------------------------------------------------------------
- // G — @Body with HttpBody
+ // G — @Content with HttpBody
// ------------------------------------------------------------------------------------------------------------------
@Remote(path = "/upload")
interface G01_UploadService {
@RemotePost
- String upload(@Body HttpBody body);
+ String upload(@Content HttpBody body);
}
@Test void g01_body_httpBody() throws Exception {
@@ -450,7 +450,7 @@ public class NgRemoteClient_Test {
@Remote(path = "/m")
interface M01_VerbService {
@RemotePut("/{id}")
- String put(@Path("id") String id, @Body String body);
+ String put(@Path("id") String id, @Content String body);
@RemotePatch("/{id}")
String patch(@Path("id") String id);
@@ -661,13 +661,13 @@ public class NgRemoteClient_Test {
}
// ------------------------------------------------------------------------------------------------------------------
- // S — @Body param with HttpBody type (explicit @Body annotation, non-String arg)
+ // S — @Content param with HttpBody type (explicit @Content annotation, non-String arg)
// ------------------------------------------------------------------------------------------------------------------
@Remote(path = "/s")
interface S01_BodyAnnotatedHttpBodyService {
@RemotePost
- String upload(@Body HttpBody body);
+ String upload(@Content HttpBody body);
}
@Test void s01_body_annotated_httpbody() throws Exception {
diff --git a/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java b/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
index 96b1b08a04..b3fc653f71 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyResource.java
@@ -1746,10 +1746,10 @@ public class ThirdPartyProxyResource extends BasicRestServlet {
@FormData("f1") String f1
) {
- assertEquals("dummy-1", p1);
- assertEquals("dummy-2", h1);
- assertEquals("dummy-3", q1);
- assertEquals("dummy-4", f1);
+ assertEquals("'1'", p1);
+ assertEquals("'2'", h1);
+ assertEquals("'3'", q1);
+ assertEquals("'4'", f1);
return "OK";
}
diff --git a/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxy_Test.java b/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxy_Test.java
index 76515b7a3a..182d159c24 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxy_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxy_Test.java
@@ -2117,10 +2117,10 @@ class ThirdPartyProxy_Test extends TestBase {
@RemoteOp(method="POST", path="/partFormatters/{p1}")
String partFormatters(
- @Path(value="p1", serializer=DummyPartSerializer.class) String p1,
- @Header(value="h1", serializer=DummyPartSerializer.class) String h1,
- @Query(value="q1", serializer=DummyPartSerializer.class) String q1,
- @FormData(value="f1", serializer=DummyPartSerializer.class) String f1
+ @Path(value="p1") String p1,
+ @Header(value="h1") String h1,
+ @Query(value="q1") String q1,
+ @FormData(value="f1") String f1
);
//-------------------------------------------------------------------------------------------------------------
diff --git a/todo/decouple-rest-common-from-marshall.md b/todo/decouple-rest-common-from-marshall.md
new file mode 100644
index 0000000000..f363aa8dab
--- /dev/null
+++ b/todo/decouple-rest-common-from-marshall.md
@@ -0,0 +1,141 @@
+# Decouple `juneau-rest-common` from `juneau-marshall`
+
+## Goal
+
+Break juneau-rest-common's compile-time dependency on juneau-marshall so the module chain becomes:
+
+```
+juneau-commons -> juneau-rest-common -> juneau-marshall -> juneau-rest-client
+ -> juneau-rest-server
+```
+
+Currently juneau-rest-common depends on juneau-marshall for:
+- `@Schema`, `InvalidAnnotationException` (83 files)
+- `MediaType`, `MediaRanges`, `StringRanges` (26 files)
+- `HttpPartSerializer`, `HttpPartSchema`, `HttpPartType` (12 files)
+- `Serializer`, `SerializerSession` (4 files)
+- `OpenApiSerializer` (3 files)
+- `BeanCreator` (3 files)
+- `VarResolverSession` (2 files)
+- `JsonSchemaSerializer`, `Json5Serializer` (2 files)
+- `UrlEncodingSerializer` (1 file)
+
+---
+
+## Phase 1 — Move `MediaType`, `MediaRanges`, `StringRanges` to `juneau-commons`
+
+**Difficulty**: Medium
+**Impact**: 26 files in rest-common
+
+These are fundamental HTTP types that don't need serializer/parser infrastructure. Move from `org.apache.juneau` (marshall root package) to `org.apache.juneau.commons.http` or similar in juneau-commons.
+
+### Classes to move
+- `MediaType`
+- `MediaRange`
+- `MediaRanges`
+- `StringRange`
+- `StringRanges`
+- `Constants` (if only used for media type constants)
+
+### Considerations
+- These types are used pervasively across marshall, rest-server, and rest-client
+- Must assess whether `MediaType` depends on anything else in marshall
+- Package rename may be needed to avoid split-package issues
+
+---
+
+## Phase 2 — Move `@Schema` and related annotations to `juneau-commons`
+
+**Difficulty**: Hard
+**Impact**: 83 files (7 HTTP annotations + Swagger model classes)
+
+`@Schema` is the #1 blocker. Every HTTP annotation references it via `Schema schema() default @Schema`. `InvalidAnnotationException` is also used.
+
+### Classes to move
+- `org.apache.juneau.annotation.Schema` → `org.apache.juneau.commons.annotation.Schema`
+- `org.apache.juneau.annotation.Items` → `org.apache.juneau.commons.annotation.Items`
+- `org.apache.juneau.annotation.SubItems` → `org.apache.juneau.commons.annotation.SubItems`
+- `org.apache.juneau.annotation.ExternalDocs` → `org.apache.juneau.commons.annotation.ExternalDocs`
+- `InvalidAnnotationException`
+
+### Considerations
+- `SchemaAnnotation` (empty(), DEFAULT, builder utilities) must also move or be split
+- `@Schema` references `JsonSchemaSerializer` in javadoc — javadoc link would break
+- `HttpPartSchema` reads `@Schema` attributes — must check if `HttpPartSchema` can also move or if reflective access suffices
+
+---
+
+## Phase 3 — Move `HttpPartSchema` and related types to `juneau-commons`
+
+**Difficulty**: Hard
+**Impact**: 12 files in rest-common
+
+`HttpPartSchema` is the schema model built from `@Schema` annotations. If `@Schema` moves to commons, `HttpPartSchema` should follow.
+
+### Classes to move
+- `org.apache.juneau.httppart.HttpPartSchema`
+- `org.apache.juneau.httppart.HttpPartType`
+- `org.apache.juneau.httppart.HttpPartDataType`
+- `org.apache.juneau.httppart.HttpPartCollectionFormat`
+- `org.apache.juneau.httppart.HttpPartFormat`
+
+### Classes to keep in marshall
+- `HttpPartSerializer` and `HttpPartParser` (interface + implementations depend on serializer infrastructure)
+- `HttpPartMarshalling` (references serializer/parser types)
+
+### Considerations
+- `HttpPartSchema.Builder` currently has `apply(HttpPartMarshalling)` which reads `serializer()`/`parser()` — this creates a dependency on marshall. Could be split: schema model in commons, marshalling-aware builder extension in marshall.
+
+---
+
+## Phase 4 — Extract `Serialized*` bridge classes
+
+**Difficulty**: Medium
+**Impact**: 3 files (SerializedHeader, SerializedPart, SerializedEntity) + 3 factory helpers
+
+These classes have the heaviest marshall dependencies — they use `httppart`, `oapi`, `serializer`, and `urlencoding` packages. They bridge the gap between REST-common HTTP types and marshall serialization.
+
+### Options
+1. **Move to marshall**: These classes logically belong in the serialization layer
+2. **Create bridge module**: `juneau-rest-bridge` between commons and marshall
+3. **Keep in rest-common with optional dependency**: Use reflection to optionally load serializers
+
+### Recommendation
+Move `SerializedHeader`, `SerializedPart`, `SerializedEntity` and their factory methods from `HttpHeaders`/`HttpParts`/`HttpEntities` to juneau-marshall or a new bridge module. The base `Basic*` classes in rest-common would remain serializer-free.
+
+---
+
+## Phase 5 — Remove remaining marshall dependencies
+
+**Difficulty**: Low-Medium
+
+### VarResolverSession (2 files)
+- `HeaderList` and `PartList` use SVL variable resolution
+- Option: Make SVL resolution optional via interface/callback
+
+### BeanCreator (3 files in httppart.bean)
+- Used by `RequestBeanMeta`/`ResponseBeanMeta` for bean construction
+- Option: Use `ClassInfo.newInstance()` from commons instead, or move `BeanCreator` to commons
+
+### Assertion types (19 files)
+- `juneau-assertions` is already a separate module
+- Rest-common should depend on `juneau-assertions` directly, not transitively through marshall
+
+---
+
+## Dependency Surface Summary
+
+| Priority | Package | Files | Target Module |
+|----------|---------|-------|---------------|
+| 1 | `MediaType`, `MediaRanges`, etc. | 26 | juneau-commons |
+| 2 | `@Schema`, `@Items`, `@SubItems` | 83 | juneau-commons |
+| 3 | `HttpPartSchema`, `HttpPartType` | 12 | juneau-commons |
+| 4 | `Serialized*` bridge classes | 6 | juneau-marshall or bridge |
+| 5 | `VarResolverSession`, `BeanCreator` | 5 | juneau-commons or optional |
+
+## Risk Notes
+
+- **Split-package**: Moving `MediaType` from `org.apache.juneau` requires a new package name in commons
+- **Binary compatibility**: All moves require recompilation of downstream modules
+- **Schema complexity**: `@Schema` has ~50 attributes and deep integration with serializers
+- **Incremental approach**: Each phase should be self-contained and buildable independently