org.fishbolt.common.flags
Class FlagsContainer

java.lang.Object
  extended by org.fishbolt.common.flags.FlagsContainer

public class FlagsContainer
extends java.lang.Object

This interface uses the int type as a bit field. It provides an empty constructor (without arguments) and a constructor with the known flags state that should be set using the bitwise "AND".


Field Summary
protected  int flags
          stores flags state.
 
Constructor Summary
protected FlagsContainer()
          Creates an instance with empty flags.
  FlagsContainer(int flags)
          Creates an instance with the specified flags.
 
Method Summary
 boolean contains(int... flags)
          Checks if at least one of the defined parameters conforms to the flags state.
 int getFlags()
          returns the current flags state
protected  int remove(int... flags)
          Removes the defined flags.
protected  int setup(int... flags)
          Sets the defined flags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flags

protected int flags
stores flags state.

Constructor Detail

FlagsContainer

protected FlagsContainer()
Creates an instance with empty flags.


FlagsContainer

public FlagsContainer(int flags)
Creates an instance with the specified flags.

Parameters:
flags - initial flags
Method Detail

getFlags

public int getFlags()
returns the current flags state

Returns:
current flags state

contains

public boolean contains(int... flags)
Checks if at least one of the defined parameters conforms to the flags state. From the logical point of view the parameter delimiter (the comma) is analogous to the logical "OR" operation

Parameters:
flags - to check if at least one of the defined.
Returns:
true when at least one of the defined, otherwise false

setup

protected int setup(int... flags)
Sets the defined flags. Only whose bits that have been physically set as a result of this operation will be set in the returned value

Parameters:
flags - flags to be setup
Returns:
bits that have been physically set.

remove

protected int remove(int... flags)
Removes the defined flags. Only whose bits that have been physically removed as a result of this operation will be unset in the returned value.

Parameters:
flags - flags to be removed
Returns:
bits that have been physically unset.