de.mguennewig.pobjects.metadata
Class UniqueConstraint

java.lang.Object
  extended by de.mguennewig.pobjects.metadata.Constraint
      extended by de.mguennewig.pobjects.metadata.UniqueConstraint
Direct Known Subclasses:
PrimaryKeyConstraint

public class UniqueConstraint
extends Constraint

Defines a unique-constraint for an n-tuple of attributes.

Use Field.isUnique() for a unique constraints on a single field.

Author:
Michael Günnewig

Field Summary
 
Fields inherited from class de.mguennewig.pobjects.metadata.Constraint
MEMBER_NAME
 
Constructor Summary
UniqueConstraint(java.lang.String schemaName, Field[] fields)
          Creates a new unique constraint.
UniqueConstraint(java.lang.String schemaName, Field[] fields, java.lang.String applyFunction)
          Creates a new unique constraint.
 
Method Summary
 void check(Record obj)
          Checks whether the constraint is fulfilled for the given object.
 java.lang.String getApplyFunction()
           
 Field getField(int i)
           
 Field[] getFields()
           
 Index getImplicitIndex()
           
 int getNumFields()
           
 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

UniqueConstraint

public UniqueConstraint(java.lang.String schemaName,
                        Field[] fields)
Creates a new unique constraint.

Parameters:
schemaName - The constraint name within the database schema.
fields - The fields belonging to this constraint.

UniqueConstraint

public UniqueConstraint(java.lang.String schemaName,
                        Field[] fields,
                        java.lang.String applyFunction)
Creates a new unique constraint.

Parameters:
schemaName - The constraint name within the database schema.
fields - The fields belonging to this constraint.
applyFunction - The name of a function to apply to all fields or null if no function should be applied.
Method Detail

getNumFields

public final int getNumFields()

getField

public final Field getField(int i)

getFields

public final Field[] getFields()

getApplyFunction

public final java.lang.String getApplyFunction()

getImplicitIndex

public final Index getImplicitIndex()

check

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

As we can't check this in-memory, this method does nothing.

Specified by:
check in class Constraint
Throws:
PObjConstraintException - when the constraint isn't fulfilled.

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 unique<TableName><Fields>