jklustor-all-api-0.0.7-20140619012755 (ChemAxon)


com.chemaxon.apidiscovery
Class Discovery

Object
  extended by com.chemaxon.apidiscovery.Discovery

@Beta
public final class Discovery
extends Object

Utility methods for parameter discovery.

Please note that this class is marked with Beta annotation, so it can be subject of incompatible changes or removal in later releases.

Author:
Gabor Imre

Method Summary
static Description getDescriptionAnnotation(Object o)
          Retrieve the description annotation on an object.
static
<T> Optional<ParameterBuilder<T>>
initializeBuilderIfExists(T o)
          Create initial Builder if possible.
static boolean isParametrized(Object o)
          Check if an object is parametrized.
static
<T> List<CreatorWrapper<T>>
listCreators(Object o, Class<T> targetType)
          CreatorWrapper acts as a type-dependent service loader.
static
<T> List<InstanceWrapper<T>>
listInstances(Class<T> type)
          Collect instances of a specific type.
static List<ParameterWrapper> listParameters(Object o)
          Retrieve parameters for a mutable parameter object.
static
<T> Optional<InstanceWrapper<T>>
selectInstance(Class<T> type, String shortName)
          Look up an instance by its short name.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

listInstances

@Beta
public static <T> List<InstanceWrapper<T>> listInstances(Class<T> type)
Collect instances of a specific type.

Type Parameters:
T - Type to collect
Parameters:
type - Type to collect
Returns:
One or more instances of the specified type. Interfaces are retrieved as services; classes are instantiated with their nullary constructors; enums are enumerated

selectInstance

public static <T> Optional<InstanceWrapper<T>> selectInstance(Class<T> type,
                                                              String shortName)
Look up an instance by its short name.

Type Parameters:
T - Type to collect
Parameters:
type - Type to collect (by listInstances(java.lang.Class)
shortName - Short name of the instance to select
Returns:
The first matching instance if found

isParametrized

@Beta
public static boolean isParametrized(Object o)
Check if an object is parametrized.

Parameters:
o - Object in question
Returns:
true if o is parametrized

listParameters

@Beta
public static List<ParameterWrapper> listParameters(Object o)
Retrieve parameters for a mutable parameter object.

Parameters:
o - Mutable parametrized object annotated with Parametrized
Returns:
Parameters of o wrapped
Throws:
IllegalArgumentException - when o is not annotated with Parametrized or no parameters found

getDescriptionAnnotation

@Beta
public static Description getDescriptionAnnotation(Object o)
Retrieve the description annotation on an object.

Parameters:
o - Object to examine
Returns:
The description annotation if exists or null; If o is an instance of an enum then enum constant annotation is retrieved
Throws:
IllegalArgumentException - when no Description annotation found

listCreators

@Beta
public static <T> List<CreatorWrapper<T>> listCreators(Object o,
                                                            Class<T> targetType)
CreatorWrapper acts as a type-dependent service loader.

Note that the order of the returned list is defined by

Type Parameters:
T - type to be created
Parameters:
targetType - type to be created
o - Instance on which the creators should be called
Returns:
All distinct creator parameters

initializeBuilderIfExists

@Beta
public static <T> Optional<ParameterBuilder<T>> initializeBuilderIfExists(T o)
Create initial Builder if possible.

Builder association is identified by annotation BuilderClass

Type Parameters:
T - Parameter object type
Parameters:
o - An object
Returns:
An associated builder instance if the parameter object has associated builder.

jklustor-all-api-0.0.7-20140619012755 (ChemAxon)