protected ForeignKeyConstraint buildForeignKeyConstraint(List<String> fkFieldNames,List<String> pkFieldNames,TableDefinition targetTable,DatabasePlatform platform){
  assert fkFieldNames.size() > 0 && fkFieldNames.size() == pkFieldNames.size();
  ForeignKeyConstraint fkConstraint=new ForeignKeyConstraint();
  for (int i=0; i < fkFieldNames.size(); i++) {
    fkConstraint.getSourceFields().add(fkFieldNames.get(i));
    fkConstraint.getTargetFields().add(pkFieldNames.get(i));
  }
  fkConstraint.setTargetTable(targetTable.getFullName());
  String fkFieldName=fkFieldNames.get(0);
  String name=buildForeignKeyConstraintName(this.getName(),fkFieldName,platform.getMaxForeignKeyNameSize(),platform);
  fkConstraint.setName(name);
  return fkConstraint;
}

protected ForeignKeyConstraint buildForeignKeyConstraint ( List < String > fkFieldNames , List < String > pkFieldNames , TableDefinition targetTable , DatabasePlatform platform ) { assert fkFieldNames . size ( ) > 0 && fkFieldNames . size ( ) == pkFieldNames . size ( ) ; ForeignKeyConstraint fkConstraint = new ForeignKeyConstraint ( ) ; for ( int i = 0 ; i < fkFieldNames . size ( ) ; i ++ ) { fkConstraint . getSourceFields ( ) . add ( fkFieldNames . get ( i ) ) ; fkConstraint . getTargetFields ( ) . add ( pkFieldNames . get ( i ) ) ; } fkConstraint . setTargetTable ( targetTable . getFullName ( ) ) ; String fkFieldName = fkFieldNames . get ( 0 ) ; String name = buildForeignKeyConstraintName ( this . getName ( ) , fkFieldName , platform . getMaxForeignKeyNameSize ( ) , platform ) ; fkConstraint . setName ( name ) ; return fkConstraint ; }
build a foreign key constraint .
