All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.infomaximum.cluster.graphql.struct.GOptional Maven / Gradle / Ivy

The newest version!
package com.infomaximum.cluster.graphql.struct;

/**
 * Created by kris on 06.03.17.
 */
public final class GOptional {

    private static final GOptional NOT_PRESENT = new GOptional(null, false);

    private final T value;
    private final boolean isPresent;

    public GOptional(T value, boolean isPresent) {
        this.value = value;
        this.isPresent = isPresent;
    }

    public T get() {
        return value;
    }

    public boolean isPresent() {
        return isPresent;
    }

    @SuppressWarnings("unchecked")
    public static final  GOptional notPresent() {
        return (GOptional) NOT_PRESENT;
    }

    public static final  GOptional of(T value) {
        return new GOptional(value, true);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy