public final boolean test(final TypeMirror receiver, final TypeMirror payload) {
// https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#observer_resolution
@@ -230,6 +283,12 @@ private final boolean assignable(final DeclaredType receiver, final DeclaredType
}; // end switch(payload)
}
+
+ /*
+ * Static methods.
+ */
+
+
// Returns a new IllegalArgumentException describing an illegal payload type.
private static IllegalArgumentException illegalPayload(final TypeMirror payload) {
return new IllegalArgumentException("Illegal payload kind: " + payload.getKind() + "; payload: " + payload);
diff --git a/src/main/java/org/microbean/event/EventTypes.java b/src/main/java/org/microbean/event/EventTypes.java
index 0ac90eb..ecafb3f 100644
--- a/src/main/java/org/microbean/event/EventTypes.java
+++ b/src/main/java/org/microbean/event/EventTypes.java
@@ -34,7 +34,15 @@
import static java.lang.System.Logger.Level.WARNING;
-// Experimental and basically located in the wrong package and module.
+/**
+ * A utility for working with event types.
+ *
+ * @author Laird Nelson
+ *
+ * @see #eventTypes(TypeMirror)
+ *
+ * @see #legalEventType(TypeMirror)
+ */
public final class EventTypes extends Types {
@@ -51,6 +59,13 @@ public final class EventTypes extends Types {
*/
+ /**
+ * Creates a new {@link EventTypes}.
+ *
+ * @param domain a {@link Domain}; must not be {@code null}
+ *
+ * @exception NullPointerException if {@code domain} is {@code null}
+ */
public EventTypes(final Domain domain) {
super(domain);
}
@@ -61,6 +76,25 @@ public EventTypes(final Domain domain) {
*/
+ /**
+ * Returns an immutable {@link List} of {@linkplain #legalEventType(TypeMirror) legal event types} that the supplied
+ * {@link TypeMirror} bears.
+ *
+ * The returned {@link List} may be empty.
+ *
+ * @param t a {@link TypeMirror}; must not be {@code null}
+ *
+ * @return an immutable {@link List} of {@linkplain #legalEventType(TypeMirror) legal event types} that the supplied
+ * {@link TypeMirror} bears; never {@code null}
+ *
+ * @exception NullPointerException if {@code t} is {@code null}
+ *
+ * @microbean.nullability This method never returns {@code null}.
+ *
+ * @microbean.idempotency This method is idempotent and returns determinate values.
+ *
+ * @microbean.threadsafety This method is safe for concurrent use by multiple threads.
+ */
public final List extends TypeMirror> eventTypes(final TypeMirror t) {
// https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#event_types_and_qualifier_types
if (t.getKind() == TypeKind.DECLARED) {
@@ -84,6 +118,32 @@ public final List extends TypeMirror> eventTypes(final TypeMirror t) {
*/
+ /**
+ * Returns {@code true} if and only if the supplied {@link TypeMirror} is a legal event type.
+ *
+ * Legal event types are, exactly:
+ *
+ *
+ *
+ * - {@linkplain TypeKind#ARRAY Array} types whose {@linkplain ArrayType#getComponentType() component type}s are
+ * legal event types
+ *
+ * - {@linkplain TypeKind#DECLARED Declared} types that contain no {@linkplain TypeKind#WILDCARD wildcard type}s for
+ * every level of containment
+ *
+ *
+ *
+ * @param t a {@link TypeMirror}; must not be {@code null}
+ *
+ * @return {@code true} if and only if {@code t} is a legal bean type; {@code false} otherwise
+ *
+ * @exception NullPointerException if {@code t} is {@code null}
+ *
+ * @microbean.idempotency This method is idempotent and deterministic.
+ *
+ * @microbean.threadsafety This method itself is safe for concurrent use by multiple threads, but {@link TypeMirror}
+ * implementations and {@link Domain} implementations may not be safe for such use.
+ */
public static final boolean legalEventType(final TypeMirror t) {
// https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#event_types_and_qualifier_types
return switch (t.getKind()) {
@@ -128,6 +188,24 @@ public static final boolean legalEventType(final TypeMirror t) {
}
+ /**
+ * Returns {@code true} if and only if the supplied {@link TypeMirror} is a legal observed event type.
+ *
+ * A legal observed event type is any Java type
+ * that a method parameter may bear.
+ *
+ * @param t a {@link TypeMirror}; must not be {@code null}
+ *
+ * @return {@code true} if and only if {@code t} is a legal observed event type; {@code false} otherwise
+ *
+ * @exception NullPointerException if {@code t} is {@code null}
+ *
+ * @microbean.idempotency This method is idempotent and deterministic.
+ *
+ * @microbean.threadsafety This method itself is safe for concurrent use by multiple threads, but {@link TypeMirror}
+ * implementations and {@link Domain} implementations may not be safe for such use.
+ */
public static final boolean legalObservedEventType(final TypeMirror t) {
// https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#event_types_and_qualifier_types
// "Any Java type [that a method parameter element may bear] may be an observed event type."
@@ -137,5 +215,4 @@ public static final boolean legalObservedEventType(final TypeMirror t) {
};
}
-
}