
package griffon.core.events;

import griffon.annotations.core.Nonnull;
import griffon.core.event.Event;

import static java.util.Objects.requireNonNull;

/**
 * @author Andres Almiray
 * @since 3.0.0
 */
public class NewInstanceEvent<T> extends Event {
    private final Class<T> type;
    private final T instance;

    @Nonnull
    public static <T> NewInstanceEvent<T> of(@Nonnull Class<T> type, @Nonnull T instance) {
        return new NewInstanceEvent<>(type, instance);
    }

    public NewInstanceEvent(@Nonnull Class<T> type, @Nonnull T instance) {
        this.type = requireNonNull(type, "Argument 'type' must not be null");
        this.instance = requireNonNull(instance, "Argument 'instance' must not be null");
    }

    @Nonnull
    public Class<T> getType() {
        return type;
    }

    @Nonnull
    public T getInstance() {
        return instance;
    }
}
