com.xqbase.util.concurrent.Count Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xqbase-util-jdk17 Show documentation
Show all versions of xqbase-util-jdk17 Show documentation
Reusable Java components for www.xqbase.com
package com.xqbase.util.concurrent;
import java.util.concurrent.atomic.AtomicInteger;
public class Count extends AtomicInteger {
private static final long serialVersionUID = 1L;
public static final Count ZERO = new Count(0);
private Count(int initialValue) {
super(initialValue);
}
protected Count() {
this(0);
}
@Override
public int hashCode() {
return (get() == 0 ? 0 : super.hashCode());
}
@Override
public boolean equals(Object obj) {
if (obj == ZERO) {
return get() == 0;
}
if (this == ZERO) {
return ((Count) obj).get() == 0;
}
return super.equals(obj);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy