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 ec0fc90f92 Utility class modernization
ec0fc90f92 is described below
commit ec0fc90f9211601dfbaa601c12f80e57c04aec6b
Author: James Bognar <[email protected]>
AuthorDate: Thu Nov 6 12:41:04 2025 -0500
Utility class modernization
---
.../org/apache/juneau/common/reflect/ClassInfo.java | 18 ------------------
.../org/apache/juneau/common/reflect/FieldInfo.java | 11 -----------
.../apache/juneau/common/reflect/MethodInfo.java | 21 +--------------------
.../apache/juneau/common/utils/PredicateUtils.java | 18 ------------------
.../rest/client/remote/RemoteOperationMeta.java | 20 ++++++++++----------
.../java/org/apache/juneau/rest/RestContext.java | 4 ++--
6 files changed, 13 insertions(+), 79 deletions(-)
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
index a17d338981..7c6a095803 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
@@ -526,24 +526,6 @@ public class ClassInfo extends ElementInfo implements
Annotatable {
return getAnnotation(null, type, filter);
}
- /**
- * Constructs an {@link AnnotationList} of all annotations found on
this class.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
- * <li>On the package of this class.
- * <li>On interfaces ordered parent-to-child.
- * <li>On parent classes ordered parent-to-child.
- * <li>On this class.
- * </ol>
- *
- * @return A new {@link AnnotationList} object on every call.
- */
- public AnnotationList getAnnotationList() {
- return AnnotationInfo.getAnnotationList(this);
- }
-
/**
* Returns all annotations of the specified type defined on this or
parent classes/interfaces.
*
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
index 4acdc3dc3f..9757582666 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/FieldInfo.java
@@ -179,17 +179,6 @@ public class FieldInfo extends AccessibleInfo implements
Comparable<FieldInfo>,
return t.orElse(null);
}
- /**
- * Returns the specified annotation on this field.
- *
- * @param <A> The annotation type to look for.
- * @param type The annotation to look for.
- * @return The annotation, or <jk>null</jk> if not found.
- */
- public <A extends Annotation> A getAnnotation(Class<A> type) {
- return
getAnnotationInfo(type).map(AnnotationInfo::inner).orElse(null);
- }
-
/**
* Returns metadata about the declaring class.
*
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
index 8496bccf4a..53877ea963 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/MethodInfo.java
@@ -451,7 +451,7 @@ public class MethodInfo extends ExecutableInfo implements
Comparable<MethodInfo>
public <A extends Annotation> Stream<AnnotationInfo<A>>
getAllAnnotationInfosParentFirst(Class<A> type) {
return rstream(getAllAnnotationInfos())
.map(x -> x.cast(type))
- .filter(notNull());
+ .filter(Objects::nonNull);
}
public Stream<MethodInfo> getMatching() {
@@ -482,25 +482,6 @@ public class MethodInfo extends ExecutableInfo implements
Comparable<MethodInfo>
.orElse(null);
}
- /**
- * Constructs an {@link AnnotationList} of all annotations found on
this method.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
- * <li>On the package of this class.
- * <li>On interfaces ordered parent-to-child.
- * <li>On parent classes ordered parent-to-child.
- * <li>On this class.
- * <li>On this method and matching methods ordered parent-to-child.
- * </ol>
- *
- * @return A new {@link AnnotationList} object on every call.
- */
- public AnnotationList getAnnotationList() {
- return AnnotationInfo.getAnnotationList(this);
- }
-
/**
* Returns the first annotation in the specified list on this method.
*
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/PredicateUtils.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/PredicateUtils.java
index c7b0ab65c4..0ddd6d6651 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/PredicateUtils.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/utils/PredicateUtils.java
@@ -243,22 +243,4 @@ public final class PredicateUtils {
public static Predicate<ElementInfo> isAny(ElementFlag...flags) {
return ei -> ei.isAny(flags);
}
-
- /**
- * Returns a predicate that tests if an object is not null.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bjava'>
- * List<String> strings = ...;
- * List<String> nonNullStrings = strings.stream()
- * .filter(notNull())
- * .collect(Collectors.toList());
- * </p>
- *
- * @param <T> The input type of the predicate.
- * @return A predicate that returns {@code true} if the input is not
null, {@code false} otherwise.
- */
- public static <T> Predicate<T> notNull() {
- return t -> t != null;
- }
}
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
index 3b990a2bbd..39a34f9685 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteOperationMeta.java
@@ -147,7 +147,7 @@ public class RemoteOperationMeta {
private void processContentDefaults(MethodInfo mi) {
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(Content.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(c -> {
String def = c.def();
@@ -157,7 +157,7 @@ public class RemoteOperationMeta {
});
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(ContentAnnotation.Array.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(x -> {
for (var c : x.value()) {
@@ -172,7 +172,7 @@ public class RemoteOperationMeta {
private static void processFormDataDefaults(MethodInfo mi,
Map<String,String> defaults) {
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(FormData.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(fd -> {
String name = firstNonEmpty(fd.name(),
fd.value());
@@ -183,7 +183,7 @@ public class RemoteOperationMeta {
});
rstream(mi.getAllAnnotationInfos())
.map(x ->
x.cast(FormDataAnnotation.Array.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(x -> {
for (var fd : x.value()) {
@@ -200,7 +200,7 @@ public class RemoteOperationMeta {
// Check for individual @Header annotations
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(Header.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(h -> {
String name = firstNonEmpty(h.name(),
h.value());
@@ -212,7 +212,7 @@ public class RemoteOperationMeta {
// Check for @Header.Array (repeated annotations)
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(HeaderAnnotation.Array.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(x -> {
for (var h : x.value()) {
@@ -228,7 +228,7 @@ public class RemoteOperationMeta {
private static void processPathDefaults(MethodInfo mi,
Map<String,String> defaults) {
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(Path.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(p -> {
String name = firstNonEmpty(p.name(),
p.value());
@@ -239,7 +239,7 @@ public class RemoteOperationMeta {
});
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(PathAnnotation.Array.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(x -> {
for (var p : x.value()) {
@@ -255,7 +255,7 @@ public class RemoteOperationMeta {
private static void processQueryDefaults(MethodInfo mi,
Map<String,String> defaults) {
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(Query.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(q -> {
String name = firstNonEmpty(q.name(),
q.value());
@@ -266,7 +266,7 @@ public class RemoteOperationMeta {
});
rstream(mi.getAllAnnotationInfos())
.map(x -> x.cast(QueryAnnotation.Array.class))
- .filter(notNull())
+ .filter(Objects::nonNull)
.map(AnnotationInfo::inner)
.forEach(x -> {
for (var q : x.value()) {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 577ff127b9..7195c37b5a 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -1767,7 +1767,7 @@ public class RestContext extends Context {
y -> beanStore.add(
x.getType().inner(),
y,
-
RestInjectAnnotation.name(x.getAnnotation(RestInject.class))
+
RestInjectAnnotation.name(x.getAnnotationInfo(RestInject.class).map(AnnotationInfo::inner).orElse(null))
)
));
// @formatter:on
@@ -1804,7 +1804,7 @@ public class RestContext extends Context {
resource.get(),
beanStore.getBean(
x.getType().inner(),
-
RestInjectAnnotation.name(x.getAnnotation(RestInject.class))
+
RestInjectAnnotation.name(x.getAnnotationInfo(RestInject.class).map(AnnotationInfo::inner).orElse(null))
).orElse(null)
));
// @formatter:on