de.mguennewig.pobjects.metadata
Class CheckConstraint

java.lang.Object
  extended by de.mguennewig.pobjects.metadata.Constraint
      extended by de.mguennewig.pobjects.metadata.CheckConstraint

public class CheckConstraint
extends Constraint

A constraint which checks whether a given boolean expression evaluates to true or unknown (when a column is null).

The expression is limited by the chosen DBMS. The in-memory checks are further restricted, see Terms.evalTerm(Term,Record) for details.

Author:
Michael Günnewig

Field Summary
 
Fields inherited from class de.mguennewig.pobjects.metadata.Constraint
MEMBER_NAME
 
Constructor Summary
CheckConstraint(java.lang.String schemaName, Predicate expression)
          Create a new check constraint.
 
Method Summary
 void check(Record obj)
          Checks whether the constraint is fulfilled for the given object.
 Column[] getColumns()
          Returns the list of columns on which this constraint operates.
 Predicate getExpression()
          Returns the boolean expression that must evaluate to true or null.
 java.lang.String name(ClassDecl te, int variant)
          Returns different names depending on variant for the code generator.
 
Methods inherited from class de.mguennewig.pobjects.metadata.Constraint
getSchemaName, isImplicit
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckConstraint

public CheckConstraint(java.lang.String schemaName,
                       Predicate expression)
Create a new check constraint.

Method Detail

getColumns

public final Column[] getColumns()
Returns the list of columns on which this constraint operates.


getExpression

public final Predicate getExpression()
Returns the boolean expression that must evaluate to true or null.

See Also:
check(de.mguennewig.pobjects.Record)

check

public void check(Record obj)
           throws PObjConstraintException
Checks whether the constraint is fulfilled for the given object.

If the expression is not supported to test in-memory then this constraint is ignored and it must be tested by the DBMS.

Specified by:
check in class Constraint
Throws:
PObjConstraintException - when the constraint isn't fulfilled.
See Also:
Terms.evalTerm(Term,Record)

name

public java.lang.String name(ClassDecl te,
                             int variant)
Returns different names depending on variant for the code generator.

Specified by:
name in class Constraint
Returns:
variant return value
Constraint.MEMBER_NAME check<TableName><Columns>