Package org.ldaptive.beans.spring
Class SpelAttributeValueMutator
java.lang.Object
org.ldaptive.beans.spring.SpelAttributeValueMutator
- All Implemented Interfaces:
AttributeValueMutator
Attribute mutator that uses a SPEL expression and evaluation context.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Attribute
Attribute containing the SPEL expression.private final org.springframework.expression.EvaluationContext
Evaluation context.private final org.springframework.expression.Expression
SPEL expression to access values.protected final org.slf4j.Logger
Logger for this class.private final ValueTranscoder
Custom transcoder for this attribute. -
Constructor Summary
ConstructorsConstructorDescriptionSpelAttributeValueMutator
(Attribute attr, org.springframework.expression.EvaluationContext context) Creates a new spel attribute value mutator. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> T
convertValue
(Object value, Class<?> sourceType, Class<T> targetType) Converts the supplied value to the target type.protected static <T> Collection<T>
createCollection
(Class<?> type, int size) Creates a best fit collection for the supplied type.Collection<byte[]>
getBinaryValues
(Object object) Returns the binary values of the attribute.getName()
Returns the name of the attribute.getStringValues
(Object object) Returns the string values of the attribute.protected <T> Collection<T>
Uses the configured expression and evaluation context to retrieve values from the supplied object.boolean
isBinary()
Returns whether the attribute is binary.void
setBinaryValues
(Object object, Collection<byte[]> values) Sets the binary values of the attribute.void
setStringValues
(Object object, Collection<String> values) Sets the string values of the attribute.protected <T> void
setValues
(Object object, Collection<T> values, Class<T> type) Uses the configured expression and evaluation context to set values on the supplied object.toString()
-
Field Details
-
logger
protected final org.slf4j.Logger loggerLogger for this class. -
attribute
Attribute containing the SPEL expression. -
expression
private final org.springframework.expression.Expression expressionSPEL expression to access values. -
evaluationContext
private final org.springframework.expression.EvaluationContext evaluationContextEvaluation context. -
transcoder
Custom transcoder for this attribute.
-
-
Constructor Details
-
SpelAttributeValueMutator
public SpelAttributeValueMutator(Attribute attr, org.springframework.expression.EvaluationContext context) Creates a new spel attribute value mutator.- Parameters:
attr
- containing the SPEL configurationcontext
- containing the values
-
-
Method Details
-
getName
Description copied from interface:AttributeValueMutator
Returns the name of the attribute.- Specified by:
getName
in interfaceAttributeValueMutator
- Returns:
- attribute name
-
isBinary
public boolean isBinary()Description copied from interface:AttributeValueMutator
Returns whether the attribute is binary.- Specified by:
isBinary
in interfaceAttributeValueMutator
- Returns:
- whether the attribute is binary
-
getStringValues
Description copied from interface:AttributeValueMutator
Returns the string values of the attribute.- Specified by:
getStringValues
in interfaceAttributeValueMutator
- Parameters:
object
- containing attribute values- Returns:
- attribute values
-
getBinaryValues
Description copied from interface:AttributeValueMutator
Returns the binary values of the attribute.- Specified by:
getBinaryValues
in interfaceAttributeValueMutator
- Parameters:
object
- containing attribute values- Returns:
- attribute values
-
getValues
Uses the configured expression and evaluation context to retrieve values from the supplied object. Values are the placed in a collection and returned.- Type Parameters:
T
- either String or byte[]- Parameters:
object
- to get values fromtype
- of objects to place in the collection- Returns:
- values in the supplied object
-
convertValue
Converts the supplied value to the target type. If a custom transcoder has been configured it is used. Otherwise the type converter from the evaluation context is used.- Type Parameters:
T
- either String or byte[]- Parameters:
value
- to convertsourceType
- to convert fromtargetType
- to convert to- Returns:
- converted value
-
setStringValues
Description copied from interface:AttributeValueMutator
Sets the string values of the attribute.- Specified by:
setStringValues
in interfaceAttributeValueMutator
- Parameters:
object
- to set values onvalues
- to set
-
setBinaryValues
Description copied from interface:AttributeValueMutator
Sets the binary values of the attribute.- Specified by:
setBinaryValues
in interfaceAttributeValueMutator
- Parameters:
object
- to set values onvalues
- to set
-
setValues
Uses the configured expression and evaluation context to set values on the supplied object. If a custom transcoder has been configured it is executed on the values before they are passed to the expression.- Type Parameters:
T
- either String or byte[]- Parameters:
object
- to set values onvalues
- to settype
- of objects in the collection
-
toString
-
createCollection
Creates a best fit collection for the supplied type.- Type Parameters:
T
- collection type- Parameters:
type
- of collection to createsize
- of the collection- Returns:
- collection
-