package speiger.src.coreengine.math.bits;

public class FlagHolder {
	int flags;
	
	public FlagHolder() {}
	
	public FlagHolder(int initFlags) {
		flags = initFlags;
	}
	
	public void setFlag(int flag) { flags |= flag; }
	
	public boolean setFlag(int flag, boolean value) {
		if(isFlagSet(flag) == value) return false;
		flags = (value ? flags | flag : flags & ~flag);
		return true;
	}
	
	public void setFlags(int flags) { this.flags = flags; }
	public void flipFlag(int flag) { flags ^= flag; }
	public void clearFlag(int flag) { flags &= ~flag; }
	public void clearFlags() { flags = 0; }
	public int getFlags() { return flags; }
	
	public boolean isFlagSet(int flag) { return (flags & flag) == flag; }
	public boolean isAnyFlagSet(int flag) { return (flags & flag) != 0; }
	public boolean isFlagNotSet(int flag) { return (flags & flag) == 0; }
}
