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

com.jn.langx.util.struct.Holder Maven / Gradle / Ivy

Go to download

Java lang extensions for java6+, a supplement to , replacement of a Guava, commons-lang. Core utilities, Collection utilities, IO utilities, Cache, Configuration library ...

There is a newer version: 4.8.2
Show newest version
package com.jn.langx.util.struct;

import com.jn.langx.util.Emptys;

public class Holder implements ValueHolder {
    private V v;
    private final V initValue;

    public Holder() {
        this.initValue = null;
    }

    public Holder(final V value) {
        this.initValue = value;
        this.set(value);
    }

    public void set(final V value) {
        this.v = value;
    }

    public V get() {
        return this.v;
    }

    @Override
    public void reset() {
        this.v = initValue;
    }

    @Override
    public boolean isNull() {
        return v == null;
    }

    @Override
    public boolean isEmpty() {
        return Emptys.isEmpty(v);
    }

    @Override
    public void setHash(int hash) {
    }

    @Override
    public int getHash() {
        return v.hashCode();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy