Spring Data Core

org.springframework.data.mapping.model
Class SpELExpressionParameterValueProvider<P extends PersistentProperty<P>>

java.lang.Object
  extended by org.springframework.data.mapping.model.SpELExpressionParameterValueProvider<P>
All Implemented Interfaces:
ParameterValueProvider<P>

public class SpELExpressionParameterValueProvider<P extends PersistentProperty<P>>
extends Object
implements ParameterValueProvider<P>

ParameterValueProvider that can be used to front a ParameterValueProvider delegate to prefer a Spel expression evaluation over directly resolving the parameter value with the delegate.

Author:
Oliver Gierke

Constructor Summary
SpELExpressionParameterValueProvider(SpELExpressionEvaluator evaluator, ConversionService conversionService, ParameterValueProvider<P> delegate)
          Creates a new SpELExpressionParameterValueProvider using the given SpELExpressionEvaluator, ConversionService and ParameterValueProvider delegate to forward calls to, that resolve parameters that do not have a Spel expression configured with them.
 
Method Summary
<T> T
getParameterValue(PreferredConstructor.Parameter<T,P> parameter)
          Returns the value to be used for the given PreferredConstructor.Parameter (usually when entity instances are created).
protected
<T> T
potentiallyConvertSpelValue(Object object, PreferredConstructor.Parameter<T,P> parameter)
          Hook to allow to massage the value resulting from the Spel expression evaluation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpELExpressionParameterValueProvider

public SpELExpressionParameterValueProvider(SpELExpressionEvaluator evaluator,
                                            ConversionService conversionService,
                                            ParameterValueProvider<P> delegate)
Creates a new SpELExpressionParameterValueProvider using the given SpELExpressionEvaluator, ConversionService and ParameterValueProvider delegate to forward calls to, that resolve parameters that do not have a Spel expression configured with them.

Parameters:
evaluator - must not be null.
conversionService - must not be null.
delegate - must not be null.
Method Detail

getParameterValue

public <T> T getParameterValue(PreferredConstructor.Parameter<T,P> parameter)
Description copied from interface: ParameterValueProvider
Returns the value to be used for the given PreferredConstructor.Parameter (usually when entity instances are created).

Specified by:
getParameterValue in interface ParameterValueProvider<P extends PersistentProperty<P>>
Parameters:
parameter - must not be null.
Returns:

potentiallyConvertSpelValue

protected <T> T potentiallyConvertSpelValue(Object object,
                                            PreferredConstructor.Parameter<T,P> parameter)
Hook to allow to massage the value resulting from the Spel expression evaluation. Default implementation will leverage the configured ConversionService to massage the value into the parameter type.

Parameters:
object - the value to massage, will never be null.
parameter - the PreferredConstructor.Parameter we create the value for
Returns:

Spring Data Core

Copyright © 2011-2013-2013 Pivotal. All Rights Reserved.