org.loom.mapping
Class DefaultEventParameter

java.lang.Object
  extended by org.loom.mapping.DefaultEventParameter
All Implemented Interfaces:
AnnotationContainer, EventParameter
Direct Known Subclasses:
RequestParametersParameter

public class DefaultEventParameter
extends java.lang.Object
implements EventParameter


Field Summary
protected  java.lang.annotation.Annotation[] annotations
          the list of annotations set on this parameter
protected  Event event
          the event
protected  int index
          the zero-based parameter index
protected  java.lang.Class<?> parameterType
          the parameter class
protected  com.google.common.collect.SetMultimap<java.lang.String,PropertyValidator> parameterValidators
          the list of validators to execute for this parameter
protected  java.util.Map<java.lang.String,PropertyBinder> properties
          for complex types, the properties that can be populated
protected  PropertyBinderFactory propertyBinderFactory
           
 
Constructor Summary
DefaultEventParameter()
           
 
Method Summary
 void addValidator(PropertyValidator validator)
           
<T extends java.lang.annotation.Annotation>
T
getAnnotation(java.lang.Class<T> annotationClass)
          If the parameter has the provided annotation, return it.
 java.lang.annotation.Annotation[] getAnnotations()
           
 Converter getConverter()
           
 java.lang.String getDisplayName()
           
 Event getEvent()
           
 int getIndex()
           
 ItemMetadata getItemMetadata(int index)
           
 int getItemMetadataSize()
           
 java.lang.String getName()
           
 java.lang.Class<?> getParameterType()
           
 java.lang.Object getPropertyAsObject(java.lang.Object container, java.lang.String propertyPath)
           
 java.lang.String getPropertyAsString(java.lang.Object container, java.lang.String propertyPath, MessagesRepository repository)
           
 PropertyBinder getPropertyBinder(java.lang.String normalizedPropertyPathWithPrefix)
           
 java.lang.Class getPropertyClass()
          this method exists only to comply with the implemented interface AnnotationContainer
 java.util.Set<PropertyValidator> getValidators(java.lang.String propertyPath)
           
 java.lang.Class<?> guessCollectionGenericType()
           
 java.lang.Class<?> guessMapGenericKeyType()
           
 java.lang.Class<?> guessMapGenericValueType()
           
 boolean isCollection()
           
 boolean isMap()
           
 boolean matches(java.lang.String propertyPath)
           
 java.lang.Object populate(java.lang.Object container, ServletRequestParameters parameters, MessagesRepository repository, Messages messages)
          Return the list of created parameter values for this request
 void setAnnotations(java.lang.annotation.Annotation[] annotations)
           
 void setConverter(Converter converter)
           
 void setEvent(Event event)
           
 void setIndex(int index)
           
 void setItemMetadata(ItemMetadata[] itemMetadata)
           
 void setName(java.lang.String name)
           
 void setParameterType(java.lang.Class<?> parameterType)
           
 void setPropertyAsObject(java.util.Map<java.lang.String,java.lang.Object> parameterValues, java.lang.String propertyPath, java.lang.Object value)
          Assigns value to some property nested inside this eventParameter
 void setPropertyBinderFactory(PropertyBinderFactory propertyBinderFactory)
           
 java.lang.String toString()
           
 void validate(java.lang.Object container, Messages messages)
          execute the validations configured for this event parameter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parameterType

protected java.lang.Class<?> parameterType
the parameter class


properties

protected java.util.Map<java.lang.String,PropertyBinder> properties
for complex types, the properties that can be populated


propertyBinderFactory

protected PropertyBinderFactory propertyBinderFactory

parameterValidators

protected com.google.common.collect.SetMultimap<java.lang.String,PropertyValidator> parameterValidators
the list of validators to execute for this parameter


annotations

protected java.lang.annotation.Annotation[] annotations
the list of annotations set on this parameter


event

protected Event event
the event


index

protected int index
the zero-based parameter index

Constructor Detail

DefaultEventParameter

public DefaultEventParameter()
Method Detail

getAnnotation

public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annotationClass)
If the parameter has the provided annotation, return it. Else, return null.

Specified by:
getAnnotation in interface AnnotationContainer
Returns:
the instance of the provided annotation class, null if none is present.

getEvent

public Event getEvent()

setEvent

public void setEvent(Event event)

getIndex

public int getIndex()

setIndex

public void setIndex(int index)

setPropertyBinderFactory

public void setPropertyBinderFactory(PropertyBinderFactory propertyBinderFactory)

addValidator

public void addValidator(PropertyValidator validator)
Specified by:
addValidator in interface EventParameter

getValidators

public java.util.Set<PropertyValidator> getValidators(java.lang.String propertyPath)
Specified by:
getValidators in interface EventParameter

setAnnotations

public void setAnnotations(java.lang.annotation.Annotation[] annotations)

getAnnotations

public java.lang.annotation.Annotation[] getAnnotations()
Specified by:
getAnnotations in interface AnnotationContainer
Returns:
the list of annotations assigned to this container

getParameterType

public java.lang.Class<?> getParameterType()
Specified by:
getParameterType in interface EventParameter

getPropertyClass

public java.lang.Class getPropertyClass()
this method exists only to comply with the implemented interface AnnotationContainer

Specified by:
getPropertyClass in interface AnnotationContainer
Returns:
the class of this property/parameter

setParameterType

public void setParameterType(java.lang.Class<?> parameterType)

guessCollectionGenericType

public java.lang.Class<?> guessCollectionGenericType()
Specified by:
guessCollectionGenericType in interface AnnotationContainer

guessMapGenericKeyType

public java.lang.Class<?> guessMapGenericKeyType()
Specified by:
guessMapGenericKeyType in interface AnnotationContainer

guessMapGenericValueType

public java.lang.Class<?> guessMapGenericValueType()
Specified by:
guessMapGenericValueType in interface AnnotationContainer

isCollection

public boolean isCollection()
Specified by:
isCollection in interface AnnotationContainer
Returns:
true if this property is a List, Set or Array

isMap

public boolean isMap()
Specified by:
isMap in interface AnnotationContainer
Returns:
true if this property is a Map

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

populate

public java.lang.Object populate(java.lang.Object container,
                                 ServletRequestParameters parameters,
                                 MessagesRepository repository,
                                 Messages messages)
Description copied from interface: EventParameter
Return the list of created parameter values for this request

Specified by:
populate in interface EventParameter

validate

public void validate(java.lang.Object container,
                     Messages messages)
Description copied from interface: EventParameter
execute the validations configured for this event parameter

Specified by:
validate in interface EventParameter
Parameters:
container - the event parameter value
messages - where validation errors will be added

getPropertyBinder

public PropertyBinder getPropertyBinder(java.lang.String normalizedPropertyPathWithPrefix)
Specified by:
getPropertyBinder in interface EventParameter
Parameters:
normalizedPropertyPathWithPrefix - the property path including the parameter name

matches

public boolean matches(java.lang.String propertyPath)
Specified by:
matches in interface EventParameter
Returns:
true if this EventParameter handles the proposed property path

getPropertyAsObject

public java.lang.Object getPropertyAsObject(java.lang.Object container,
                                            java.lang.String propertyPath)
Specified by:
getPropertyAsObject in interface EventParameter

getPropertyAsString

public java.lang.String getPropertyAsString(java.lang.Object container,
                                            java.lang.String propertyPath,
                                            MessagesRepository repository)
Specified by:
getPropertyAsString in interface EventParameter

getName

public java.lang.String getName()
Specified by:
getName in interface AnnotationContainer
Returns:
the name of this method or property

setName

public void setName(java.lang.String name)

getConverter

public Converter getConverter()
Specified by:
getConverter in interface EventParameter

setConverter

public void setConverter(Converter converter)

getDisplayName

public java.lang.String getDisplayName()
Specified by:
getDisplayName in interface AnnotationContainer
Returns:
the name used to display error or informational messages

setPropertyAsObject

public void setPropertyAsObject(java.util.Map<java.lang.String,java.lang.Object> parameterValues,
                                java.lang.String propertyPath,
                                java.lang.Object value)
Assigns value to some property nested inside this eventParameter

Specified by:
setPropertyAsObject in interface EventParameter

setItemMetadata

public void setItemMetadata(ItemMetadata[] itemMetadata)

getItemMetadata

public ItemMetadata getItemMetadata(int index)
Specified by:
getItemMetadata in interface AnnotationContainer

getItemMetadataSize

public int getItemMetadataSize()
Specified by:
getItemMetadataSize in interface AnnotationContainer