Class Klass<C>

java.lang.Object
org.kohsuke.stapler.lang.Klass<C>
Type Parameters:
C - Variable that represents the type of Class 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 for Class.

This is a convenient tuple so that we can pass around a single argument instead of two.

Author:
Kohsuke Kawaguchi
  • Field Details

    • clazz

      public final C clazz
  • Constructor Details

  • Method Details

    • getResource

      public URL getResource(String resourceName)
    • getAncestors

      public Iterable<Klass<?>> getAncestors()
    • getSuperClass

      public Klass<?> getSuperClass()
    • toJavaClass

      public Class toJavaClass()
    • getDeclaredMethods

      public List<MethodRef> getDeclaredMethods()
      Since:
      1.220
    • 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:
    • 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()
    • getMapElement

      public Object getMapElement(Object o, String key)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • java

      public static Klass<Class> java(Class c)
      Creates Klass from a Java Class.