Package org.instancio

Interface OnCompleteCallback<T>

  • Type Parameters:
    T - type handled by the callback
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface OnCompleteCallback<T>
    A callback that gets invoked after an object has been fully populated.
    Since:
    1.0.4
    • Method Detail

      • onComplete

        void onComplete​(T object)
        A callback method that is called after an object has been populated.

        If a null value is generated for a selector with a callback, the callback will not be invoked.

        In the following snippet, all Phone instances are nullable and also have a callback associated with them. The callback will only be called when a non-null value is generated.

        
             Person person = Instancio.of(Person.class)
                 .withNullable(all(Phone.class))
                 .onComplete(all(Phone.class), (Phone phone) -> {
                     // will only be called on non-null phones
                 })
                 .create();
         
        Parameters:
        object - fully populated instance to call the callback on
        Since:
        1.0.4