package speiger.src.coreengine.math.bits;

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