public class BuilderHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
NAME_KEY
The key for the name field of the tokenized string
|
static String |
QUALIFIER_KEY
The key for the qualifier field of the tokenized string
|
static String |
TOKEN_SEPARATOR
The token separator
|
Constructor and Description |
---|
BuilderHelper() |
Modifier and Type | Method and Description |
---|---|
static ActiveDescriptorBuilder |
activeLink(Class<?> implementationClass)
This method creates an
ActiveDescriptorBuilder , whose job it
is to create an unreified ActiveDescriptor . |
static Filter |
allFilter()
Returns a filter of type Descriptor that matches
all descriptors
|
static <T> AbstractActiveDescriptor<T> |
createConstantDescriptor(T constant)
This creates a descriptor that will always return the given object.
|
static <T> AbstractActiveDescriptor<T> |
createConstantDescriptor(T constant,
String name,
Type... contracts)
This creates a descriptor that will always return the given object.
|
static <T> ServiceHandle<T> |
createConstantServiceHandle(T obj)
Creates a ServiceHandle that will always return the given object from
the
ServiceHandle.getService() method. |
static IndexedFilter |
createContractFilter(String contract)
Returns an indexed filter that will return all descriptors that
have contract as an advertised contract
|
static DescriptorImpl |
createDescriptorFromClass(Class<?> clazz)
This returns a DescriptorImpl based on the given class.
|
static IndexedFilter |
createNameAndContractFilter(String contract,
String name)
Returns an indexed filter that will return all descriptors that
have the given name and given contract
|
static IndexedFilter |
createNameFilter(String name)
Returns an indexed filter that will return all descriptors that
have the given name
|
static IndexedFilter |
createSpecificDescriptorFilter(Descriptor descriptor)
This method creates a filter that will match one and only one descriptor.
|
static IndexedFilter |
createTokenizedFilter(String tokenString)
Creates a filter from a token string as per the following rules.
The token delimiter is ;
The first token is the contract.
|
static DescriptorImpl |
deepCopyDescriptor(Descriptor copyMe)
Makes a deep copy of the incoming descriptor
|
static boolean |
filterMatches(Descriptor baseDescriptor,
Filter filter)
Determines if the given descriptor matches the given filter.
|
static void |
getMetadataValues(Annotation annotation,
Map<String,List<String>> metadata)
This is a helper method that gets the metadata values from the
Metadata annotations found in an annotation. |
static DescriptorBuilder |
link(Class<?> implementationClass)
This method links an implementation class with a
DescriptorBuilder , to
be used to further build the Descriptor . |
static DescriptorBuilder |
link(Class<?> implementationClass,
boolean addToContracts)
This method links an implementation class with a
DescriptorBuilder , to
be used to further build the Descriptor |
static DescriptorBuilder |
link(String implementationClass)
This method links an implementation class with a
DescriptorBuilder , to
be used to further build the Descriptor . |
static DescriptorBuilder |
link(String implementationClass,
boolean addToContracts)
This method links an implementation class with a
DescriptorBuilder , to
be used to further build the Descriptor . |
public static final String NAME_KEY
public static final String QUALIFIER_KEY
public static final String TOKEN_SEPARATOR
public static IndexedFilter createContractFilter(String contract)
contract
- The advertised contract to look forpublic static IndexedFilter createNameFilter(String name)
name
- The name to look forpublic static IndexedFilter createNameAndContractFilter(String contract, String name)
contract
- The advertised contract to look forname
- The name to look forpublic static IndexedFilter createTokenizedFilter(String tokenString) throws IllegalArgumentException
The following are examples of valid token strings:
tokenString
- A non-null string following the rules stated aboveIllegalArgumentException
- If the token string is invalid in some waypublic static IndexedFilter createSpecificDescriptorFilter(Descriptor descriptor)
descriptor
- The descriptor from which to create a filterpublic static Filter allFilter()
public static DescriptorBuilder link(String implementationClass, boolean addToContracts) throws IllegalArgumentException
DescriptorBuilder
, to
be used to further build the Descriptor
.implementationClass
- The fully qualified name of the implementation
class to be associated with the DescriptorBuilder.addToContracts
- if true, this implementation class will be added to the
list of contractsDescriptorBuilder
that can be used to further build up the
Descriptor
IllegalArgumentException
- if implementationClass is nullpublic static DescriptorBuilder link(String implementationClass) throws IllegalArgumentException
DescriptorBuilder
, to
be used to further build the Descriptor
. This method will automatically
put the implementationClass into the list of advertised contracts.implementationClass
- The fully qualified name of the implementation
class to be associated with the PredicateBuilder.DescriptorBuilder
that can be used to further build up the
Descriptor
IllegalArgumentException
- if implementationClass is nullpublic static DescriptorBuilder link(Class<?> implementationClass, boolean addToContracts) throws IllegalArgumentException
DescriptorBuilder
, to
be used to further build the Descriptor
implementationClass
- The implementation class to be associated
with the DescriptorBuilder
.addToContracts
- true if this impl class should be automatically added to
the list of contractsDescriptorBuilder
that can be used to further build up the
Descriptor
IllegalArgumentException
- if implementationClass is nullpublic static DescriptorBuilder link(Class<?> implementationClass) throws IllegalArgumentException
DescriptorBuilder
, to
be used to further build the Descriptor
.implementationClass
- The implementation class to be associated
with the DescriptorBuilder
.DescriptorBuilder
that can be used to further build up the
Descriptor
IllegalArgumentException
- if implementationClass is nullpublic static ActiveDescriptorBuilder activeLink(Class<?> implementationClass) throws IllegalArgumentException
ActiveDescriptorBuilder
, whose job it
is to create an unreified ActiveDescriptor
. The implementation
class given will NOT automatically be added to the set of contracts
of the ActiveDescriptor
.implementationClass
- The implementation class to be associated
with the ActiveDescriptorBuilder
.ActiveDescriptorBuilder
that can be used to further build up the
Descriptor
IllegalArgumentException
- if implementationClass is nullpublic static <T> AbstractActiveDescriptor<T> createConstantDescriptor(T constant)
constant
- The non-null constant that should always be returned from
the create method of this ActiveDescriptor.IllegalArgumentException
- if constant is nullpublic static <T> AbstractActiveDescriptor<T> createConstantDescriptor(T constant, String name, Type... contracts)
constant
- The non-null constant that should always be returned from
the create method of this ActiveDescriptor.name
- The possibly null name that should be associated with this constant descriptorcontracts
- The possibly empty set of contracts that should be associated with this
descriptorIllegalArgumentException
- if constant is nullpublic static DescriptorImpl createDescriptorFromClass(Class<?> clazz)
clazz
- The class to analyzepublic static DescriptorImpl deepCopyDescriptor(Descriptor copyMe)
copyMe
- The descriptor to copypublic static void getMetadataValues(Annotation annotation, Map<String,List<String>> metadata)
Metadata
annotations found in an annotation.annotation
- The annotation to find Metadata
values
from. May not be null.metadata
- A non-null metadata map. The values found in the
annotation will be added to this metadata mapIllegalArgumentException
- if annotation or metadata is nullMultiException
- if there was an error invoking the methods of the annotationpublic static <T> ServiceHandle<T> createConstantServiceHandle(T obj)
ServiceHandle.getService()
method. The ServiceHandle.getActiveDescriptor()
will return null and the ServiceHandle.destroy()
method will
do nothingobj
- The object to be associated with this ServiceHandle. May be nullServiceHandle
that will always return the given valuepublic static boolean filterMatches(Descriptor baseDescriptor, Filter filter)
Filter
implements IndexedFilter
.baseDescriptor
- The non-null descriptor to match the filter againstfilter
- The filter to match. If null will return trueCopyright © 2009-2016 Oracle Corporation. All Rights Reserved.