net.percederberg.mibble.type
Class CompoundConstraint

java.lang.Object
  extended bynet.percederberg.mibble.type.CompoundConstraint
All Implemented Interfaces:
Constraint

public class CompoundConstraint
extends java.lang.Object
implements Constraint

A compound MIB type constraint. This class holds two constraints, either one that must be compatible for this constraint to return true. Effectively this class represents an OR composition of the two constraints.

Since:
2.0

Constructor Summary
CompoundConstraint(Constraint first, Constraint second)
          Creates a new compound constraint.
 
Method Summary
 java.util.ArrayList getConstraintList()
          Returns a list of the constraints in this compound.
 void initialize(MibLoaderLog log)
          Initializes the constraint.
 boolean isCompatible(MibType type)
          Checks if the specified type is compatible with this constraint.
 boolean isCompatible(MibValue value)
          Checks if the specified value is compatible with this constraint set.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompoundConstraint

public CompoundConstraint(Constraint first,
                          Constraint second)
Creates a new compound constraint.

Parameters:
first - the first constraint
second - the second constraint
Method Detail

initialize

public void initialize(MibLoaderLog log)
                throws MibException
Initializes the constraint. This will remove all levels of indirection present, such as references to types or values. No constraint information is lost by this operation. This method may modify this object as a side-effect, and will be called by the MIB loader.

Specified by:
initialize in interface Constraint
Parameters:
log - the MIB loader log
Throws:
MibException - if an error was encountered during the initialization

isCompatible

public boolean isCompatible(MibType type)
Checks if the specified type is compatible with this constraint. The type is considered compatible if it is compatible with both constraints.

Specified by:
isCompatible in interface Constraint
Parameters:
type - the type to check
Returns:
true if the type is compatible, or false otherwise

isCompatible

public boolean isCompatible(MibValue value)
Checks if the specified value is compatible with this constraint set. The value is considered compatible if it is compatible with either of the two constraints.

Specified by:
isCompatible in interface Constraint
Parameters:
value - the value to check
Returns:
true if the value is compatible, or false otherwise

getConstraintList

public java.util.ArrayList getConstraintList()
Returns a list of the constraints in this compound. All compound constraints will be flattened out and their contents will be added to the list.

Returns:
a list of the base constraints in the compound

toString

public java.lang.String toString()
Returns a string representation of this object.

Returns:
a string representation of this object