public class PropertySetter extends PropertyResolver
PropertyResolver
that also can
change properties by paths based on a given Resolvable
. The setting
process resolves the given property path up to the next to last path part.
When the result of this is a Changeable
or a Collection of
Changeables, the objects are modified by setting the property given by the
last part of the property path.Resolvable
representing a user. The call to
setProperty(String, Object)
with ("organisation.employees.email",
"a.b@foo.com") would first resolve "organisation.employees" to a
Collection
of Changeable
s representing all employees of the
user's organisation and would then change the email addresses by calling
Changeable.setProperty(String, Object)
with ("email", "a.b@foo.com")
for each.PropertyResolver.PropertyPathEntry
m_startObject
Constructor and Description |
---|
PropertySetter(Resolvable baseObject)
Create a propertySetter that resolves and sets properties based on the given Resolvable.
|
Modifier and Type | Method and Description |
---|---|
void |
addToProperty(java.lang.String path,
java.lang.Object value)
Add the given property to the properties resolved by the given path.
|
void |
addToProperty(java.lang.String path,
java.lang.Object value,
boolean allowDuplicates)
Add the given property to the properties resolved by the given path.
|
void |
performAssignment(Expression expression)
Perform the given assignment expression
|
protected void |
remove(java.util.Collection toModify,
java.lang.Object toRemove)
Remove the given object from the given collection.
|
protected void |
removeAll(java.util.Collection toModify,
java.util.Collection toRemove)
Remove all objects in the collection from the given collection.
|
void |
removeFromProperty(java.lang.String path,
java.lang.Object value)
Remove the given value from the properties resolved by the given path.
|
void |
setProperty(java.lang.String path,
java.lang.Object value)
Set the property (properties) given by the path to the given value
|
canResolve, get, getProperty, resolve, resolve, resolve, resolve, resolvePath, resolvePath, resolvePath
public PropertySetter(Resolvable baseObject)
baseObject
- base objectpublic void setProperty(java.lang.String path, java.lang.Object value) throws UnknownPropertyException, InsufficientPrivilegesException
path
- path to a property/properties of an object/objectsvalue
- new value to setUnknownPropertyException
- when the property path cannot be fully resolvedInsufficientPrivilegesException
- when setting the value is not allowedpublic void addToProperty(java.lang.String path, java.lang.Object value) throws UnknownPropertyException, InsufficientPrivilegesException
path
- property pathvalue
- value to addUnknownPropertyException
- when the property path cannot be fully resolvedInsufficientPrivilegesException
- when setting the property is not allowedpublic void addToProperty(java.lang.String path, java.lang.Object value, boolean allowDuplicates) throws UnknownPropertyException, InsufficientPrivilegesException
path
- property pathvalue
- value to addallowDuplicates
- true when duplicates are allowed, false if notUnknownPropertyException
- when the property path cannot be fully resolvedInsufficientPrivilegesException
- when setting the property is not allowedpublic void removeFromProperty(java.lang.String path, java.lang.Object value) throws UnknownPropertyException, InsufficientPrivilegesException
path
- path of the propertyvalue
- value to removeUnknownPropertyException
- when the property path cannot be fully resolvedInsufficientPrivilegesException
- when changing the property is not allowedpublic void performAssignment(Expression expression) throws ExpressionParserException
expression
- assignment expressionExpressionParserException
- when assignment failsprotected void remove(java.util.Collection toModify, java.lang.Object toRemove)
toModify
- collection to modifytoRemove
- object to removeprotected void removeAll(java.util.Collection toModify, java.util.Collection toRemove)
toModify
- collection to modifytoRemove
- collection of objects to removeCopyright © 2022 Gentics Software. All Rights Reserved.