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

jpower.core.Wrapper Maven / Gradle / Ivy

There is a newer version: 0.0.5
Show newest version
package jpower.core;

public class Wrapper
{

    private T value;

    public Wrapper(T value)
    {
        this.value = value;
    }

    public T get()
    {
        return value;
    }

    public T set(T value)
    {
        T old = get();
        this.value = value;
        return old;
    }

    public boolean isNull()
    {
        return get() == null;
    }

    @Override
    public boolean equals(Object obj)
    {
        return value == obj || value != null && obj.getClass() == value.getClass() && value.equals(obj);
    }

    @Override
    public int hashCode()
    {
        return value == null ? 0 : value.hashCode();
    }

    public static  Wrapper of(T value)
    {
        return new Wrapper<>(value);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy