+ public static <T extends EnumTypeObject> @NonNull T checkEnum(final @Nullable T obj, final String name) {
+ if (obj == null) {
+ throw new IllegalArgumentException("\"" + name + "\" is not a valid name");
+ }
+ return obj;
+ }
+
+ /**
+ * Check that the specified {@link EnumTypeObject} object is not {@code null}. This method is meant to be used with
+ * {@code ofName(String)} and {@code ofValue(int)} static factory methods.
+ *
+ * @param obj enumeration object, possibly {@code null}
+ * @param value User-supplied enumeration value
+ * @return Enumeration object
+ * @throws IllegalArgumentException if {@code obj} is {@code null}
+ */
+ public static <T extends EnumTypeObject> @NonNull T checkEnum(final @Nullable T obj, final int value) {
+ if (obj == null) {
+ throw new IllegalArgumentException(value + " is not a valid value");
+ }
+ return obj;
+ }
+
+ /**
+ * Utility method for checking whether a target object is a compatible {@link BindingContract}.
+ *
+ * @param requiredClass Required BindingContract class
+ * @param obj Object to check, may be {@code null}
+ * @return Object cast to required class, if its implemented class matches requirement, {@code null} otherwise
+ * @throws NullPointerException if {@code requiredClass} is {@code null}
+ */
+ public static <T extends BindingContract<?>> @Nullable T checkCast(final @NonNull Class<T> requiredClass,