Package org.instancio
Interface Selector
- All Superinterfaces:
ConvertibleToScope
,GroupableSelector
,TargetSelector
- All Known Implementing Classes:
MetamodelSelector
,PrimitiveAndWrapperSelectorImpl
,SelectorImpl
- Since:
- 1.2.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionSpecifies the scope for this selector in order to narrow down its target.Methods inherited from interface org.instancio.ConvertibleToScope
toScope
-
Method Details
-
within
Specifies the scope for this selector in order to narrow down its 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:// Scope can be created using: Scope cellPhone = scope(Person.class, "cell"); // or selector toScope() method Scope cellPhone = field(Person::getCell).toScope(); Person person = Instancio.of(Person.class) .set(field(Phone.class, "number").within(cellPhone), "123-45-67") .create();
See Selector Scopes section of the user guide for details.
- Parameters:
scopes
- one or more scopes to apply- Returns:
- a selector with the specified scope
- Since:
- 1.3.0
-