com.jn.langx.util.struct.Holder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of langx-java Show documentation
Show all versions of langx-java Show documentation
Java lang extensions for java6+, a supplement to , replacement of a Guava, commons-lang.
Core utilities, Collection utilities, IO utilities, Cache, Configuration library ...
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();
}
}