public final class AnnotationSupport extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
getContext(Object target)
Gets the value of the field indicated by the
Context annotation on the given object. |
static Long |
getExpiration(Object target)
Gets the value of the field indicated by the
Expiration annotation on the given object,
or null if none. |
static String |
getKey(Object target)
Gets the value of the field indicated by the
Key annotation on the given object. |
static String |
getValue(Object target)
Gets the value of the field indicated by the
Value annotation on the given object. |
static void |
setContext(Object target,
String context)
Sets the value of the field indicated by the
Context annotation on the given object. |
static void |
setExpiration(Object target,
Long expiration)
Sets the value of the field indicated by the
Expiration annotation on the given object. |
static void |
setKey(Object target,
String key)
Sets the value of the field indicated by the
Key annotation on the given object. |
static void |
setValue(Object target,
String value)
Sets the value of the field indicated by the
Value annotation on the given object. |
@Nonnull @NotEmpty public static String getContext(@Nonnull Object target)
Context annotation on the given object.
If the value is not a String, then it is converted to one
by calling Object.toString() on the object.
target - object from which to get contextIllegalArgumentException - if the target object doesn't declare a Context annotationRuntimeException - if the field cannot be read on the target objectpublic static void setContext(@Nonnull Object target, @Nonnull @NotEmpty String context)
Context annotation on the given object.target - Object on which to set contextcontext - Context valueIllegalArgumentException - if the target object doesn't declare a Context annotationRuntimeException - if the field cannot be set on the target object@Nonnull @NotEmpty public static String getKey(@Nonnull Object target)
Key annotation on the given object.
If the value is not a String, then it is converted to one
by calling Object.toString() on the object.
target - object from which to get keyIllegalArgumentException - if the target object doesn't declare a Key annotationRuntimeException - if the field cannot be read on the target objectpublic static void setKey(@Nonnull Object target, @Nonnull @NotEmpty String key)
Key annotation on the given object.target - Object on which to set keykey - Key valueIllegalArgumentException - if the target object doesn't declare a Key annotationRuntimeException - if the field cannot be set on the target object@Nonnull @NotEmpty public static String getValue(@Nonnull Object target)
Value annotation on the given object.
If the value is not a String, then it is converted to one
by calling Object.toString() on the object.
target - Object from which to get valueIllegalArgumentException - if the target object doesn't declare a Value annotationRuntimeException - if the field cannot be read on the target objectpublic static void setValue(@Nonnull Object target, @Nonnull @NotEmpty String value)
Value annotation on the given object.target - object on which to set valuevalue - Value field valueIllegalArgumentException - if the target object doesn't declare a Value annotationRuntimeException - if the field cannot be set on the target object@Nullable public static Long getExpiration(@Nonnull Object target)
Expiration annotation on the given object,
or null if none.
The value is returned as a long, in milliseconds since the beginning of the Unix epoch. The following data types are supported:
longDateReadableInstanttarget - Object from which to get expirationIllegalArgumentException - if the target object doesn't declare a Expiration annotationRuntimeException - if the field cannot be read on the target object or if it is an unsupported data typepublic static void setExpiration(@Nonnull Object target, @Nullable Long expiration)
Expiration annotation on the given object.
The expiration is expressed in milliseconds since the beginning of the Unix epoch. The following data types are supported:
longDateReadableInstanttarget - object on which to set expirationexpiration - value to setIllegalArgumentException - if the target object doesn't declare a Expiration annotationRuntimeException - if the field cannot be set on the target object or if it is an unsupported data typeCopyright © 2021. All rights reserved.