org.openpermis.policy.bean
Class SerialNumber

java.lang.Object
  extended by org.openpermis.policy.bean.SerialNumber
All Implemented Interfaces:
Serializable

public final class SerialNumber
extends Object
implements Serializable

Serial number of a part.

Serial numbers are unique with respect to their context:

The serial number UNDEFINED is a special serial number that does not have a context. Use this serial number for parts that do not need to have a well-defined serial number. Note that undefined serial numbers return an undefined serial number if they are asked to create the next() serial number.

See Also:
Serialized Form
Since:
0.1.0

Nested Class Summary
private static class SerialNumber.Context
          Context for creating serial numbers.
 
Field Summary
private  SerialNumber.Context context
          The context in which the serial number was created.
private static long serialVersionUID
           
static SerialNumber UNDEFINED
          Virtual serial number for parts that do not have a well-defined serial number.
private  long value
          The value of this serial number.
 
Constructor Summary
private SerialNumber()
          Creates a new undefined serial number.
private SerialNumber(long value, SerialNumber.Context context)
          Creates an serial number with the specified value.
 
Method Summary
static SerialNumber create()
          Creates a new serial number which has its own numbering scheme.
 boolean equalContext(SerialNumber serial)
          Checks if this serial number lies in the same context as the one specified.
 boolean equals(Object obj)
          Compares another serial number to this one.
 int hashCode()
          Return a hash code based on the value of this serial number.
 boolean isUndefined()
          Checks if the value of this serial number is undefined.
 SerialNumber next()
          Returns the next free serial number unique with respect to the context of this serial number.
 String toString()
          Returns the hex representation of the value of this serial number.
 long value()
          Returns the value of this serial number.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Constant Field Value:
-1342243947699108706L
Since:
0.1.0

UNDEFINED

public static final SerialNumber UNDEFINED
Virtual serial number for parts that do not have a well-defined serial number.

This serial number cannot create new unique serial numbers, instead newly created serial numbers are undefined again.

See Also:
next()
Since:
0.1.0

value

private final long value
The value of this serial number.

Since:
0.1.0

context

private final SerialNumber.Context context
The context in which the serial number was created.

Since:
0.1.0
Constructor Detail

SerialNumber

private SerialNumber()
Creates a new undefined serial number.

Since:
0.1.0

SerialNumber

private SerialNumber(long value,
                     SerialNumber.Context context)
Creates an serial number with the specified value.

Parameters:
value - the value of this serial number.
Since:
0.1.0
Method Detail

create

public static final SerialNumber create()
Creates a new serial number which has its own numbering scheme.

All serial numbers are unique in respect to the initial serial number created.

Returns:
the serial number with a new context requested.
Since:
0.1.0

next

public SerialNumber next()
Returns the next free serial number unique with respect to the context of this serial number.

Undefined serial numbers return an undefined serial number as they have no context.

Returns:
the serial number requested.
Since:
0.1.0

value

public long value()
Returns the value of this serial number.

Returns:
the value of this serial number.
Since:
0.1.0

isUndefined

public boolean isUndefined()
Checks if the value of this serial number is undefined.

Returns:
true if the value of this serial number is undefined.
Since:
0.1.0

equalContext

public boolean equalContext(SerialNumber serial)
Checks if this serial number lies in the same context as the one specified.

Parameters:
serial - the serial number whose context is to be compared.
Returns:
true if the serial number specified and this serial number lie in the same context, false if they do not share the same context.
Since:
0.1.0

hashCode

public int hashCode()
Return a hash code based on the value of this serial number.

Overrides:
hashCode in class Object
Returns:
the hash code of this serial number.
Since:
0.1.0

equals

public boolean equals(Object obj)
Compares another serial number to this one.

Overrides:
equals in class Object
Parameters:
obj - the serial number to compare to this one.
Returns:
true if both serial numbers have the same context and value.
Since:
0.1.0

toString

public String toString()
Returns the hex representation of the value of this serial number.

Overrides:
toString in class Object
Returns:
the string representation of this serial number.
Since:
0.1.0


PERMIS Role Based Access Control 0.4.0 (Build 15)
2009/05/20 08:14:59
Copyright (c) 2002-2007 Ergon Informatik AG