Package org.cyclos.model.utils
Class FieldSelector
- java.lang.Object
-
- org.cyclos.model.utils.FieldSelector
-
- All Implemented Interfaces:
Serializable
public class FieldSelector extends Object implements Serializable
Abstraction for selecting which fields are included in a result- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExclude(String name, Collection<String> excluding)If the given name is excluded, add it to the given collectionvoidapply(Object object)Applies the field selection to the given object, setting to null all values that should be excludedstatic FieldSelectorempty()Collection<String>getFields()CAUTION: This method must be used only for justified cases.booleanincludes(String name)Returns whether the given path name should be included in the fieldsstatic FieldSelectorof(String... fields)static FieldSelectorof(Collection<String> fields)voidrunIf(String field, Runnable runnable)Runs the given runnable only if the specified field is included.StringtoString()
-
-
-
Method Detail
-
empty
public static FieldSelector empty()
-
of
public static final FieldSelector of(Collection<String> fields)
-
of
public static final FieldSelector of(String... fields)
-
addExclude
public void addExclude(String name, Collection<String> excluding)
If the given name is excluded, add it to the given collection
-
apply
public void apply(Object object)
Applies the field selection to the given object, setting to null all values that should be excluded
-
getFields
public Collection<String> getFields()
CAUTION: This method must be used only for justified cases. Instead, use thisincludes(String)
-
includes
public boolean includes(String name)
Returns whether the given path name should be included in the fields
-
runIf
public void runIf(String field, Runnable runnable)
Runs the given runnable only if the specified field is included. Otherwise it's a no-op.
-
-