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

com.xqbase.util.concurrent.Count Maven / Gradle / Ivy

There is a newer version: 0.2.18
Show newest version
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(1);
	}

	@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