de.smartics.properties.spi.core.registry
Class InMemoryPropertyDescriptorRegistry

Package class diagram package InMemoryPropertyDescriptorRegistry
java.lang.Object
  extended by de.smartics.properties.spi.core.registry.InMemoryPropertyDescriptorRegistry
All Implemented Interfaces:
PropertyDescriptorRegistry, Serializable, Iterable< PropertyDescriptor>

@ThreadSafe
public class InMemoryPropertyDescriptorRegistry
     
     
extends Object
implements PropertyDescriptorRegistry

A registry for a set of property descriptors stored in-memory.

The typical usage of this class is to fetch a PropertyDescriptor by its (string) key.

See Also:
Serialized Form

Constructor Summary
InMemoryPropertyDescriptorRegistry()
          Convenience constructor to start without a set of descriptor sets.
InMemoryPropertyDescriptorRegistry(Class<?>... propertySetTypes)
          Default constructor.
 
Method Summary
 void addDescriptors(Class<?>... propertySetTypes)
          Adds the given descriptors.
 void addDescriptors(Class<?> propertySetType)
          Adds the given descriptor.
 void addDescriptors(Class<?> propertySetType, List<PropertyDescriptor> descriptors)
          Adds the descriptors to the given declaring type.
 void addDescriptors(Set<Class<?>> propertySetTypes)
          Adds the given descriptors.
 List<PropertyDescriptor> createMandatoryProperties()
          Returns the list of mandatory properties.
 List<? extends PropertyDescriptor> get(Class<?> propertySet)
          Returns the descriptors for the given descriptor type.
 PropertyDescriptor get(String key)
          Returns the descriptor for the given key or null if no descriptor is registered for the given key.
 PropertiesContext getContext(Class<?> declaringType)
          Returns the property context for the given property declaring type.
 PropertiesContext getContext(PropertyDescriptor descriptor)
          Returns the property context for the given property descriptor.
 String getDocumentationUrl(PropertyDescriptor descriptor)
          Returns the URL to the documentation report for the given property descriptor.
 String getMetaInfPath(PropertyDescriptor descriptor)
          Returns the path to the context information for the given property descriptor.
 Set<Class<?>> getPropertySetTypes()
          Returns the property set types of all property descriptors that have been added.
 Iterator<PropertyDescriptor> iterator()
           
 String toString()
          Returns the string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InMemoryPropertyDescriptorRegistry

public InMemoryPropertyDescriptorRegistry()
Convenience constructor to start without a set of descriptor sets.


InMemoryPropertyDescriptorRegistry

public InMemoryPropertyDescriptorRegistry(Class<?>... propertySetTypes)
                                   throws DuplicatePropertyDeclarationException
Default constructor.

Parameters:
propertySetTypes - the array of property set types.
Throws:
DuplicatePropertyDeclarationException - if any of the descriptors declare the same property.
Method Detail

addDescriptors

public final void addDescriptors(Class<?> propertySetType,
                                 List<PropertyDescriptor> descriptors)
                          throws NullPointerException,
                                 DuplicatePropertyDeclarationsException
Description copied from interface: PropertyDescriptorRegistry
Adds the descriptors to the given declaring type.

Specified by:
addDescriptors in interface PropertyDescriptorRegistry
Parameters:
propertySetType - the type that declares the property descriptors.
descriptors - the descriptors to the given propertySetType.
Throws:
NullPointerException - if propertySetType or descriptors is null.
DuplicatePropertyDeclarationsException - if any of the descriptors declare the same property.

createMandatoryProperties

public final List<PropertyDescriptor> createMandatoryProperties()
Description copied from interface: PropertyDescriptorRegistry
Returns the list of mandatory properties.

Returns a copy that can be edited.

Specified by:
createMandatoryProperties in interface PropertyDescriptorRegistry
Returns:
the list of mandatory properties.

addDescriptors

public final void addDescriptors(Class<?> propertySetType)
                          throws DuplicatePropertyDeclarationsException
Description copied from interface: PropertyDescriptorRegistry
Adds the given descriptor.

Specified by:
addDescriptors in interface PropertyDescriptorRegistry
Parameters:
propertySetType - the property set type to add.
Throws:
DuplicatePropertyDeclarationsException - if any of the descriptors declare the same property.

addDescriptors

public final void addDescriptors(Class<?>... propertySetTypes)
                          throws DuplicatePropertyDeclarationsException
Description copied from interface: PropertyDescriptorRegistry
Adds the given descriptors.

Specified by:
addDescriptors in interface PropertyDescriptorRegistry
Parameters:
propertySetTypes - the array of property set types to add.
Throws:
DuplicatePropertyDeclarationsException - if any of the descriptors declare the same property.

addDescriptors

public final void addDescriptors(Set<Class<?>> propertySetTypes)
                          throws DuplicatePropertyDeclarationsException
Description copied from interface: PropertyDescriptorRegistry
Adds the given descriptors.

Specified by:
addDescriptors in interface PropertyDescriptorRegistry
Parameters:
propertySetTypes - the array of property set types to add.
Throws:
DuplicatePropertyDeclarationsException - if any of the descriptors declare the same property.

get

public final List<? extends PropertyDescriptor> get(Class<?> propertySet)
Description copied from interface: PropertyDescriptorRegistry
Returns the descriptors for the given descriptor type.

Specified by:
get in interface PropertyDescriptorRegistry
Parameters:
propertySet - the type for descriptors to fetch.
Returns:
the list of descriptors registered. May be the empty list, but is never null.

get

public final PropertyDescriptor get(String key)
Description copied from interface: PropertyDescriptorRegistry
Returns the descriptor for the given key or null if no descriptor is registered for the given key.

Specified by:
get in interface PropertyDescriptorRegistry
Parameters:
key - the key whose descriptor is requested.
Returns:
the descriptor to the key or null.

getContext

public final PropertiesContext getContext(PropertyDescriptor descriptor)
                                   throws ConfigException
Description copied from interface: PropertyDescriptorRegistry
Returns the property context for the given property descriptor.

Specified by:
getContext in interface PropertyDescriptorRegistry
Parameters:
descriptor - the descriptor whose context is requested.
Returns:
the requested context.
Throws:
ConfigException - if the context for the descriptor cannot be found.

getContext

public final PropertiesContext getContext(Class<?> declaringType)
                                   throws ConfigException
Description copied from interface: PropertyDescriptorRegistry
Returns the property context for the given property declaring type.

Specified by:
getContext in interface PropertyDescriptorRegistry
Parameters:
declaringType - the type whose context is requested.
Returns:
the requested context.
Throws:
ConfigException - if the context for the descriptor cannot be found.

getDocumentationUrl

public final String getDocumentationUrl(PropertyDescriptor descriptor)
                                 throws ConfigException
Description copied from interface: PropertyDescriptorRegistry
Returns the URL to the documentation report for the given property descriptor.

Specified by:
getDocumentationUrl in interface PropertyDescriptorRegistry
Parameters:
descriptor - the descriptor whose documentation is requested.
Returns:
the URL to the documentation.
Throws:
ConfigException - if the descriptors context cannot be found.

getMetaInfPath

public final String getMetaInfPath(PropertyDescriptor descriptor)
                            throws ConfigException
Description copied from interface: PropertyDescriptorRegistry
Returns the path to the context information for the given property descriptor.

Specified by:
getMetaInfPath in interface PropertyDescriptorRegistry
Parameters:
descriptor - the descriptor whose context information is requested.
Returns:
the URL to the context information.
Throws:
ConfigException - if the descriptors context cannot be found.

getPropertySetTypes

public final Set<Class<?>> getPropertySetTypes()
Description copied from interface: PropertyDescriptorRegistry
Returns the property set types of all property descriptors that have been added.

Specified by:
getPropertySetTypes in interface PropertyDescriptorRegistry
Returns:
the property set types of all property descriptors that have been added.

iterator

public final Iterator<PropertyDescriptor> iterator()
Specified by:
iterator in interface Iterable<PropertyDescriptor>

toString

public final String toString()
Returns the string representation of the object.

Overrides:
toString in class Object
Returns:
the string representation of the object.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.