Class SelectorImpl

    • 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 two Phone 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.

        Specified by:
        within in interface Selector
        Parameters:
        scopes - one or more scopes to apply
        Returns:
        a selector with the specified scope
      • getParent

        public Selector getParent()
      • getTargetClass

        public Class<?> getTargetClass()
      • getFieldName

        public String getFieldName()
      • equals

        public boolean equals​(Object o)

        Performs equality check with all fields except parent.

        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()

        Calculates hashcode using all fields except parent.

        Overrides:
        hashCode in class Object