org.openpermis.policy.predicate
Class AbstractPredicate<T>

java.lang.Object
  extended by org.openpermis.policy.predicate.AbstractPredicate<T>
Type Parameters:
T - type of the operands.
All Implemented Interfaces:
Serializable, Part, Predicate
Direct Known Subclasses:
And, Not, Or, Present, SubstringOf, ValueRelationalPredicate, ValueSetRelationalPredicate

public abstract class AbstractPredicate<T>
extends Object
implements Predicate

A node in the predicate tree consisting in a predicate having two generic operands.

See Also:
Serialized Form
Since:
0.1.0

Field Summary
 
Fields inherited from interface org.openpermis.policy.Predicate
FALSE, TRUE
 
Constructor Summary
AbstractPredicate(T... operands)
          Creates an abstract predicate with operands.
 
Method Summary
protected abstract  boolean comparablePredicate(Predicate predicate)
          Compares the type of predicate with this.
 boolean equals(Object obj)
          Check if this policy part is equivalent to the one specified.
 T getOperand(int index)
          Returns the n-th operand of this predicate.
 int getOperandCount()
          Returns the number of operands.
 List<T> getOperands()
          Returns a list of operands.
 int hashCode()
          Returns the hash code of this policy part.
 boolean isValid(PartProblemReporter reporter)
          Check if this part and all parts contained are valid.
protected abstract  int partHashCode()
          Returns the hash code of this part.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openpermis.policy.Predicate
isMatchable, isValid, matches
 
Methods inherited from interface org.openpermis.policy.Part
toString
 

Constructor Detail

AbstractPredicate

public AbstractPredicate(T... operands)
Creates an abstract predicate with operands.

Parameters:
operands - an array of operands.
Since:
0.1.0
Method Detail

getOperandCount

public int getOperandCount()
Returns the number of operands.

Returns:
the number of operands.
Since:
0.1.0

getOperand

public T getOperand(int index)
Returns the n-th operand of this predicate.

Parameters:
index - the position of the desired operand.
Returns:
the n-th operand.
Since:
0.1.0

getOperands

public List<T> getOperands()
Returns a list of operands.

Returns:
a list of operands
Since:
0.1.0

comparablePredicate

protected abstract boolean comparablePredicate(Predicate predicate)
Compares the type of predicate with this.

Parameters:
predicate - a Predicate.
Returns:
true if this is comparable to predicate.
Since:
0.1.0

partHashCode

protected abstract int partHashCode()
Returns the hash code of this part.

Returns:
hash code of this part.
Since:
0.1.0

isValid

public final boolean isValid(PartProblemReporter reporter)
Description copied from interface: Part
Check if this part and all parts contained are valid.

Instead of enforcing that a part is valid at all times a part may be invalid (for example while loading a policy from a file or while editing a part). Use this method to assert that a part is valid.

Specified by:
isValid in interface Part
Parameters:
reporter - optional callback where violiations are reported, may be null if the caller is not interested in details about the violations.
Returns:
true if the part and all parts contained are valid, false if this part or at least one part contained are invalid.
Since:
0.1.0

equals

public final boolean equals(Object obj)
Description copied from interface: Part
Check if this policy part is equivalent to the one specified.

A part is considered equivalent to this part if it's state is equivalent to the state of this part and all parts contained are equivalent to the parts contained in this policy part.

Specified by:
equals in interface Part
Overrides:
equals in class Object
Parameters:
obj - the policy part to compare this policy part to.
See Also:
Part.hashCode()
Since:
0.1.0

hashCode

public final int hashCode()
Description copied from interface: Part
Returns the hash code of this policy part.

In addition to the general contract for Object.hashCode() the hash code of a policy part should not make use of the default object hash code. Instead the hash code of a policy part should only be calculated according to the contents of the policy part in such a way that different instances of a policy part with the same content return the same hash code.

Specified by:
hashCode in interface Part
Overrides:
hashCode in class Object
Returns:
the hash code of this policy part.
See Also:
Part.equals(Object)
Since:
0.1.0


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