|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.craftforge.essential.controller.utils.AnnotationUtils
public class AnnotationUtils
Utilities for annotation actions.
| Constructor Summary | |
|---|---|
AnnotationUtils()
|
|
| Method Summary | |
|---|---|
static List<Field> |
getAnnotatedFieldsFromClass(Class<?> clazz)
Gets a list of all fields with an @Param, @Body, @Header or @Property annotation, looking them up on field level and on method level of getters and setters. |
static String |
getBestMatchingMediaType(Object supplier,
Class<? extends Annotation> annotationType,
String mediaTypes)
Gets the media type of a consumer or producer being annotated with the @Produces or @Consumes annotation which value matches best the specified media types. |
static Method |
getBestMatchingMethod(Object supplier,
Class<? extends Annotation> annotationType,
String mediaTypes)
Gets the method of a consumer or producer being annotated with the @Produces or @Consumes annotation which value matches best the specified media types. |
static List<Field> |
getBodyFieldsFromClass(Class<?> clazz)
Gets a list of all fields with an @Body annotation, looking them up on field level and on method level of getters and setters. |
static Class<?> |
getConsumerFromMethodOrClass(Method method)
Gets the @Consumer annotation value of a method, looking it up on method level first, then class level. |
static Method |
getConsumerMethod(Object consumer,
String mediaTypes)
Gets the method of a consumer being annotated with the @Consumes annotation which value matches best the media types. |
static String[] |
getDefaultValuesFromProperty(Field field)
Gets the @DefaultValue annotation value(s) of a field, looking it up on field level and on method level of getters and setters. |
static List<Field> |
getHeaderFieldsFromClass(Class<?> clazz)
Gets a list of all fields with an @Header annotation, looking them up on field level and on method level of getters and setters. |
static String |
getHeaderFromProperty(Field field)
Gets the @Header annotations value of a property, looking it up on field level and on method level of getters and setters. |
static String |
getHttpMethod(Method method)
Gets the REST annotation (@Get, @Post, etc.) of a method, looking it up on method level. |
static List<Field> |
getParamFieldsFromClass(Class<?> clazz)
Gets a list of all fields with an @Param annotation, looking them up on field level and on method level of getters and setters. |
static String |
getParamFromProperty(Field field)
Gets the @Param annotations value of a property, looking it up on field level and on method level of getters and setters. |
static String |
getPathFromClass(Class<?> clazz)
Gets the @Path annotation value of a class, looking it up on type level. |
static String |
getPathFromMethod(Method method)
Gets the @Path annotation value of a method, looking it up on method level. |
static Class<?> |
getProducerFromMethodOrClass(Method method)
Gets the @Producer annotation value of a method, looking it up on method level first, then class level. |
static Method |
getProducerMethod(Object producer,
String mediaTypes)
Gets the method of a producer being annotated with the @Produces annotation which value matches best the specified media types. |
static List<Field> |
getPropertyFieldsFromClass(Class<?> clazz)
Gets a list of all fields with an @Property annotation, looking them up on field level and on method level of getters and setters. |
static String |
getPropertyFromProperty(Field field)
Gets the @Property annotation value of a property, looking it up on field level and on method level of getters and setters. |
static List<Method> |
getResourceMethodsFromClass(Class<?> clazz)
Gets a list of all methods with a REST annotation (@Get, @Post, etc.) |
static List<String> |
getSupportedConsumerMediaTypes(Class<?> clazz)
Gets the supported consumer media types from a consumer class. |
static List<String> |
getSupportedProducerMediaTypes(Class<?> clazz)
Gets the supported producer media types from a producer class. |
static Class[][] |
getValidConsumerParameterTypes()
Gets all valid consumer parameter type combinations. |
static Class[][] |
getValidProducerParameterTypes()
Gets all valid producer parameter type combinations. |
static boolean |
isBodyOnProperty(Field field)
Determines whether the @Body annotation is present on a property, looking it up on field level and on method level of getters and setters. |
static boolean |
isPublic(Method method)
Checks if the @Public annotation is present, looking it up on method level first, then class level. |
static boolean |
isStreamingSupported(Consumer consumer,
String mediaType)
Checks if for the given media type streaming is supported by the specified consumer. |
static boolean |
isStreamingSupported(Producer producer,
String mediaType)
Checks if for the given media type streaming is supported by the specified producer. |
static boolean |
isValidConsumerMethod(Method method)
Checks if a consumer method has a valid signature. |
static boolean |
isValidMethod(Method method,
Class[][] validParameterTypes)
Checks if a method has a method signature by comparing its parameter types against a set of valid parameter type combinations. |
static boolean |
isValidProducerMethod(Method method)
Checks if a producer method has a valid signature. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AnnotationUtils()
| Method Detail |
|---|
public static String getPathFromClass(Class<?> clazz)
clazz - The class
public static String getPathFromMethod(Method method)
method - The method
public static String getParamFromProperty(Field field)
field - The field
public static String getHeaderFromProperty(Field field)
field - The field
public static String getPropertyFromProperty(Field field)
field - The field
public static boolean isBodyOnProperty(Field field)
field - The field
public static String[] getDefaultValuesFromProperty(Field field)
field - The field
public static Method getProducerMethod(Object producer,
String mediaTypes)
throws ControllerException
producer - The producer methodmediaTypes - The media types
ControllerException - Failed to find a producer method supplying one of the accepted media types
public static Method getConsumerMethod(Object consumer,
String mediaTypes)
throws ControllerException
consumer - The consumermediaTypes - The media types
ControllerException - Failed to find a consumer method supplying one of the accepted media types
public static Method getBestMatchingMethod(Object supplier,
Class<? extends Annotation> annotationType,
String mediaTypes)
throws ControllerException
supplier - The supplierannotationType - The annotation type.mediaTypes - The media types
ControllerException - Failed to find a producer method supplying one of the accepted media types
public static String getBestMatchingMediaType(Object supplier,
Class<? extends Annotation> annotationType,
String mediaTypes)
throws ControllerException
supplier - The supplierannotationType - The annotation type.mediaTypes - The media types
ControllerException - Failed to find a producer method supplying one of the accepted media typespublic static Class<?> getProducerFromMethodOrClass(Method method)
method - The method
public static Class<?> getConsumerFromMethodOrClass(Method method)
method - The method
public static boolean isPublic(Method method)
method - The method
public static List<Field> getParamFieldsFromClass(Class<?> clazz)
clazz - The class
public static List<Field> getHeaderFieldsFromClass(Class<?> clazz)
clazz - The class
public static List<Field> getBodyFieldsFromClass(Class<?> clazz)
clazz - The class
public static List<Field> getPropertyFieldsFromClass(Class<?> clazz)
clazz - The class
public static List<Field> getAnnotatedFieldsFromClass(Class<?> clazz)
clazz - The class
public static List<Method> getResourceMethodsFromClass(Class<?> clazz)
clazz - The class
public static List<String> getSupportedProducerMediaTypes(Class<?> clazz)
clazz - The producer class
public static List<String> getSupportedConsumerMediaTypes(Class<?> clazz)
clazz - The consumer class
public static Class[][] getValidConsumerParameterTypes()
public static Class[][] getValidProducerParameterTypes()
public static boolean isValidProducerMethod(Method method)
method - The producer method
public static boolean isValidConsumerMethod(Method method)
method - The consumer method
public static boolean isValidMethod(Method method,
Class[][] validParameterTypes)
method - The methodvalidParameterTypes - The valid parameter type combinations
public static boolean isStreamingSupported(Consumer consumer,
String mediaType)
throws ControllerException
consumer - The consumermediaType - The media type
ControllerException - if the specified consumer does not supply the given media type
public static boolean isStreamingSupported(Producer producer,
String mediaType)
throws ControllerException
producer - The producermediaType - The media type
ControllerException - if the specified producer does not supply the given media typepublic static String getHttpMethod(Method method)
method - The method
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||