Package org.instancio
Interface Selector
-
- All Superinterfaces:
GroupableSelector
,TargetSelector
,ToScopeConvertible
- All Known Implementing Classes:
PrimitiveAndWrapperSelectorImpl
,SelectorImpl
public interface Selector extends GroupableSelector, ToScopeConvertible
A class for selecting fields and classes.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description GroupableSelector
within(Scope... scopes)
Specifies the scope for this selector in order to narrow down the selector target.-
Methods inherited from interface org.instancio.ToScopeConvertible
toScope
-
-
-
-
Method Detail
-
within
GroupableSelector within(Scope... scopes)
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.
- Parameters:
scopes
- one or more scopes to apply- Returns:
- a selector with the specified scope
-
-