Class MethodList
- java.lang.Object
-
- org.glassfish.jersey.server.model.MethodList
-
- All Implemented Interfaces:
java.lang.Iterable<AnnotatedMethod>
public final class MethodList extends java.lang.Object implements java.lang.Iterable<AnnotatedMethod>
Iterable list of methods on a single class with convenience getters for additional method information.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
MethodList.Filter
Method list filter.
-
Field Summary
Fields Modifier and Type Field Description private AnnotatedMethod[]
methods
-
Constructor Summary
Constructors Constructor Description MethodList(java.lang.Class<?> c)
Create new method list for a class.MethodList(java.lang.Class<?> c, boolean declaredMethods)
Create new method list for a class.MethodList(java.lang.reflect.Method... methods)
Create new method list from the given array of methods.MethodList(java.util.Collection<java.lang.reflect.Method> methods)
Create new method list from the given collection of methods.MethodList(AnnotatedMethod... methods)
Create new method list from the given array ofannotated methods
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MethodList
filter(MethodList.Filter filter)
Created a new method list containing only the methods supported by themethod list filter
.private static java.util.List<java.lang.reflect.Method>
getAllDeclaredMethods(java.lang.Class<?> c)
private static java.util.List<java.lang.reflect.Method>
getMethods(java.lang.Class<?> c)
MethodList
hasNumParams(int paramCount)
Get a new sub-list of methods containing all the methods from this method list that have the specific number of parameters.MethodList
hasReturnType(java.lang.Class<?> returnType)
Get a new sub-list of methods containing all the methods from this method list that declare the specified return type.MethodList
isNotPublic()
Get a new sub-list of methods containing all the methods from this method list that are not public.java.util.Iterator<AnnotatedMethod>
iterator()
Iterator over the list ofannotated methods
contained in this method list.MethodList
nameStartsWith(java.lang.String prefix)
Get a new sub-list of methods containing all the methods from this method list with a specified method name prefix.<T extends java.lang.annotation.Annotation>
MethodListwithAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list with a specified method-level annotation declared.<T extends java.lang.annotation.Annotation>
MethodListwithMetaAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list with a method-level annotation declared that is itself annotated with a specified meta-annotation.<T extends java.lang.annotation.Annotation>
MethodListwithoutAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list without a specified method-level annotation declared.<T extends java.lang.annotation.Annotation>
MethodListwithoutMetaAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list without any method-level annotation declared that would itself be annotated with a specified meta-annotation.
-
-
-
Field Detail
-
methods
private AnnotatedMethod[] methods
-
-
Constructor Detail
-
MethodList
public MethodList(java.lang.Class<?> c)
Create new method list for a class. The method list containsall methods
available on the class. Thebridge methods
and methods declared directly on theObject
class are filtered out.- Parameters:
c
- class from which the method list is created.
-
MethodList
public MethodList(java.lang.Class<?> c, boolean declaredMethods)
Create new method list for a class. The method list containsall methods
available on the class ordeclared methods
only, depending on the value of thedeclaredMethods
parameter. Thebridge methods
and methods declared directly on theObject
class are filtered out.- Parameters:
c
- class from which the method list is created.declaredMethods
- iftrue
only thedeclared methods
will be included in the method list; otherwiseall methods
will be listed.
-
MethodList
public MethodList(java.util.Collection<java.lang.reflect.Method> methods)
Create new method list from the given collection of methods. Thebridge methods
and methods declared directly on theObject
class are filtered out.- Parameters:
methods
- methods to be included in the method list.
-
MethodList
public MethodList(java.lang.reflect.Method... methods)
Create new method list from the given array of methods. Thebridge methods
and methods declared directly on theObject
class are filtered out.- Parameters:
methods
- methods to be included in the method list.
-
MethodList
public MethodList(AnnotatedMethod... methods)
Create new method list from the given array ofannotated methods
.- Parameters:
methods
- methods to be included in the method list.
-
-
Method Detail
-
getAllDeclaredMethods
private static java.util.List<java.lang.reflect.Method> getAllDeclaredMethods(java.lang.Class<?> c)
-
getMethods
private static java.util.List<java.lang.reflect.Method> getMethods(java.lang.Class<?> c)
-
iterator
public java.util.Iterator<AnnotatedMethod> iterator()
Iterator over the list ofannotated methods
contained in this method list.- Specified by:
iterator
in interfacejava.lang.Iterable<AnnotatedMethod>
- Returns:
- method list iterator.
-
isNotPublic
public MethodList isNotPublic()
Get a new sub-list of methods containing all the methods from this method list that are not public.- Returns:
- new filtered method sub-list.
-
hasNumParams
public MethodList hasNumParams(int paramCount)
Get a new sub-list of methods containing all the methods from this method list that have the specific number of parameters.- Parameters:
paramCount
- number of method parameters.- Returns:
- new filtered method sub-list.
-
hasReturnType
public MethodList hasReturnType(java.lang.Class<?> returnType)
Get a new sub-list of methods containing all the methods from this method list that declare the specified return type.- Parameters:
returnType
- method return type.- Returns:
- new filtered method sub-list.
-
nameStartsWith
public MethodList nameStartsWith(java.lang.String prefix)
Get a new sub-list of methods containing all the methods from this method list with a specified method name prefix.- Parameters:
prefix
- method name prefix.- Returns:
- new filtered method sub-list.
-
withAnnotation
public <T extends java.lang.annotation.Annotation> MethodList withAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list with a specified method-level annotation declared.- Type Parameters:
T
- annotation type.- Parameters:
annotation
- annotation class.- Returns:
- new filtered method sub-list.
-
withMetaAnnotation
public <T extends java.lang.annotation.Annotation> MethodList withMetaAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list with a method-level annotation declared that is itself annotated with a specified meta-annotation.- Type Parameters:
T
- meta-annotation type.- Parameters:
annotation
- meta-annotation class.- Returns:
- new filtered method sub-list.
-
withoutAnnotation
public <T extends java.lang.annotation.Annotation> MethodList withoutAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list without a specified method-level annotation declared.- Type Parameters:
T
- annotation type.- Parameters:
annotation
- annotation class.- Returns:
- new filtered method sub-list.
-
withoutMetaAnnotation
public <T extends java.lang.annotation.Annotation> MethodList withoutMetaAnnotation(java.lang.Class<T> annotation)
Get a new sub-list of methods containing all the methods from this method list without any method-level annotation declared that would itself be annotated with a specified meta-annotation.- Type Parameters:
T
- meta-annotation type.- Parameters:
annotation
- meta-annotation class.- Returns:
- new filtered method sub-list.
-
filter
public MethodList filter(MethodList.Filter filter)
Created a new method list containing only the methods supported by themethod list filter
.- Parameters:
filter
- method list filter.- Returns:
- new filtered method list.
-
-