Package org.kohsuke.stapler.lang
Class Klass<C>
- java.lang.Object
-
- org.kohsuke.stapler.lang.Klass<C>
-
- Type Parameters:
C
- Variable that represents the type ofClass
like object in this language.
public final class Klass<C> extends Object
Abstraction of class-like object, agnostic to languages.To support other JVM languages that use their own specific types to represent a class (such as JRuby and Jython), we now use this object instead of
Class
. This allows us to reuse much of the logic of class traversal/resource lookup across different languages. But after the removal of JRuby support, in practice this is used only forClass
.This is a convenient tuple so that we can pass around a single argument instead of two.
- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
Fields Modifier and Type Field Description C
clazz
KlassNavigator<C>
navigator
-
Constructor Summary
Constructors Constructor Description Klass(C clazz, KlassNavigator<C> navigator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Iterable<Klass<?>>
getAncestors()
Object
getArrayElement(Object o, int index)
List<FieldRef>
getDeclaredFields()
Gets list of fields declared by the class.List<MethodRef>
getDeclaredMethods()
List<FieldRef>
getFields()
Gets all the public fields defined in this type, including super types.List<Function>
getFunctions()
Reports all the methods that can be used for routing requests on this class.Object
getMapElement(Object o, String key)
URL
getResource(String resourceName)
Klass<?>
getSuperClass()
int
hashCode()
boolean
isArray()
boolean
isMap()
static Klass<Class>
java(Class c)
Class
toJavaClass()
String
toString()
-
-
-
Field Detail
-
clazz
public final C clazz
-
navigator
public final KlassNavigator<C> navigator
-
-
Constructor Detail
-
Klass
public Klass(C clazz, KlassNavigator<C> navigator)
-
-
Method Detail
-
getSuperClass
public Klass<?> getSuperClass()
-
toJavaClass
public Class toJavaClass()
-
getDeclaredFields
@NonNull public List<FieldRef> getDeclaredFields()
Gets list of fields declared by the class.- Returns:
- List of fields.
May return empty list in the case of obsolete
navigator
, which does not offer the method. - Since:
- 1.246
-
getFields
public List<FieldRef> getFields()
Gets all the public fields defined in this type, including super types.- See Also:
Class.getFields()
-
getFunctions
@NonNull public List<Function> getFunctions()
Reports all the methods that can be used for routing requests on this class.- Returns:
- List of functions.
May return empty list in the case of obsolete
navigator
, which does not offer the method. - Since:
- 1.246
-
isArray
public boolean isArray()
-
getArrayElement
public Object getArrayElement(Object o, int index) throws IndexOutOfBoundsException
- Throws:
IndexOutOfBoundsException
-
isMap
public boolean isMap()
-
-