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


com.chemaxon.apidiscovery
Class CreatorWrapper<T>

Object
  extended by com.chemaxon.apidiscovery.CreatorWrapper<T>
Type Parameters:
T - Type of the created instance

@Beta
public class CreatorWrapper<T>
extends Object

CreatorWrapper acts as a type- and instance -dependent service loader.

A creator method simply creates an instance of a type from an instance of a parameter type. (Consider here the Descriptors API createXXXComparator methods.) When the parameter type has free parameters it should be implemented as an immutable parameter object - builder class pair. This wrapper usually wraps a default instance of such immutable parameter objects; however it returns an associated builder to change.

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

Constructor Summary
CreatorWrapper(Object creatorHost, Method creatorMethod, Object initialParameter)
          Construct a wrapper.
 
Method Summary
 T create()
          Invoke creator method.
 Object getBuilderOrParameterObject()
          Get the parameter object or its mutable builder if exists.
 String getDescription()
           
 String getName()
           
(package private)  int getOrder()
          Order stored in creator annotation.
 String getShortName()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CreatorWrapper

CreatorWrapper(Object creatorHost,
               Method creatorMethod,
               Object initialParameter)
Construct a wrapper.

Parameters:
creatorHost - Object on which a represented creator method will be called
creatorMethod - The creator method which should be called
initialParameter - The parameter reference which can be passed to the creator method
Throws:
IllegalArgumentException - when a builder or parametrized object is passed as initialParameter
Method Detail

getOrder

int getOrder()
Order stored in creator annotation.

Returns:
order from creator annotation

getBuilderOrParameterObject

public Object getBuilderOrParameterObject()
Get the parameter object or its mutable builder if exists.

If the returned object is mutable then its state will be considered upon creation

Returns:
The wrapped parameter object or its builder when exists.

getShortName

public String getShortName()

getName

public String getName()

getDescription

public String getDescription()

create

public T create()
Invoke creator method.

Use builder if exists, otherwise initial

Returns:
The created instance

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