Package org.instancio.internal.selectors
Class SelectorImpl
- java.lang.Object
-
- org.instancio.internal.selectors.SelectorImpl
-
- All Implemented Interfaces:
GroupableSelector
,Flattener
,Selector
,TargetSelector
,ToScopeConvertible
public final class SelectorImpl extends Object implements Selector, GroupableSelector, Flattener
-
-
Constructor Summary
Constructors Constructor Description SelectorImpl(SelectorTargetType selectorTargetType, Class<?> targetClass, String fieldName)
SelectorImpl(SelectorTargetType selectorTargetType, Class<?> targetClass, String fieldName, List<Scope> scopes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
List<SelectorImpl>
flatten()
String
getFieldName()
List<Scope>
getScopes()
Class<?>
getTargetClass()
int
hashCode()
SelectorTargetType
selectorType()
Scope
toScope()
Scope representation of a selector.String
toString()
Selector
within(Scope... scopes)
Specifies the scope for this selector in order to narrow down the selector target.
-
-
-
Constructor Detail
-
SelectorImpl
public SelectorImpl(SelectorTargetType selectorTargetType, @Nullable Class<?> targetClass, @Nullable String fieldName, @Nullable List<Scope> scopes)
-
SelectorImpl
public SelectorImpl(SelectorTargetType selectorTargetType, @Nullable Class<?> targetClass, @Nullable String fieldName)
-
-
Method Detail
-
within
public Selector within(Scope... scopes)
Description copied from interface:Selector
Specifies the scope for this selector in order to narrow down the selector target.For example, if the
Person
class has twoPhone
fields:class Person { private Phone home; private Phone cell; // snip... }
and we want to set only the
cell
phone to a specific value, we can narrow down the selector as follows:Person person = Instancio.of(Person.class) .set(field(Phone.class, "number").within(scope(Person.class, "cell")), "123-45-67") .create();
Multiple scopes can be specified top-down, that is starting from the outermost class.
-
toScope
public Scope toScope()
Description copied from interface:ToScopeConvertible
Scope representation of a selector.- Specified by:
toScope
in interfaceToScopeConvertible
- Returns:
- scope
-
selectorType
public SelectorTargetType selectorType()
-
getTargetClass
public Class<?> getTargetClass()
-
getFieldName
public String getFieldName()
-
flatten
public List<SelectorImpl> flatten()
-
-