de.mguennewig.pobjects.metadata
Class PrimaryKeyConstraint

java.lang.Object
  extended by de.mguennewig.pobjects.metadata.Constraint
      extended by de.mguennewig.pobjects.metadata.UniqueConstraint
          extended by de.mguennewig.pobjects.metadata.PrimaryKeyConstraint

public class PrimaryKeyConstraint
extends UniqueConstraint

A primary key constraint is a UniqueConstraint which also forbids null values.

Author:
Michael Günnewig

Field Summary
 
Fields inherited from class de.mguennewig.pobjects.metadata.Constraint
MEMBER_NAME
 
Constructor Summary
PrimaryKeyConstraint(java.lang.String schemaName, Field[] fields)
          Creates a new primary-key constraint.
PrimaryKeyConstraint(java.lang.String schemaName, IdField idfield)
          Creates the implicit primary-key constraint for the id field.
 
Method Summary
 void check(Record obj)
          Checks whether the constraint is fulfilled for the given Record.
 java.lang.String name(ClassDecl cl, int variant)
          Returns different names depending on variant for the code generator.
 
Methods inherited from class de.mguennewig.pobjects.metadata.UniqueConstraint
getApplyFunction, getField, getFields, getImplicitIndex, getNumFields
 
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

PrimaryKeyConstraint

public PrimaryKeyConstraint(java.lang.String schemaName,
                            Field[] fields)
Creates a new primary-key constraint.

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

PrimaryKeyConstraint

public PrimaryKeyConstraint(java.lang.String schemaName,
                            IdField idfield)
Creates the implicit primary-key constraint for the id field.

Method Detail

check

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

As we can't check for uniqueness we only check whether each field is NOT NULL.

Overrides:
check in class UniqueConstraint
Throws:
PObjConstraintException - when the constraint isn't fulfilled.

name

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

Overrides:
name in class UniqueConstraint
Returns:
variant return value
Constraint.MEMBER_NAME pk<TableName><Fields>