Skip to content

Commit

Permalink
HHH-7031 TableSpecification.locateForeignKey impl
Browse files Browse the repository at this point in the history
  • Loading branch information
stliu committed Feb 8, 2012
1 parent c134154 commit a096b1c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Expand Up @@ -59,7 +59,7 @@ public Iterable<SimpleValue> values() {

@Override
public Column locateOrCreateColumn(String name) {
if(values.containsKey( name )){
if ( values.containsKey( name ) ) {
return (Column) values.get( name );
}
final Column column = new Column( this, values.size(), name );
Expand All @@ -69,7 +69,7 @@ public Column locateOrCreateColumn(String name) {

@Override
public DerivedValue locateOrCreateDerivedValue(String fragment) {
if(values.containsKey( fragment )){
if ( values.containsKey( fragment ) ) {
return (DerivedValue) values.get( fragment );
}
final DerivedValue value = new DerivedValue( this, values.size(), fragment );
Expand All @@ -94,6 +94,31 @@ public ForeignKey createForeignKey(TableSpecification targetTable, String name)
return fk;
}

@Override
public ForeignKey locateForeignKey(String name) {
for ( ForeignKey fk : foreignKeys ) {
if ( fk.getName().equals( name ) ) {
return fk;
}
}
return null;
}

@Override
public Iterable<ForeignKey> locateForeignKey(TableSpecification targetTable) {
List<ForeignKey> result = null;
for ( ForeignKey fk : foreignKeys ) {
if ( fk.getTargetTable().equals( targetTable ) ) {
if ( result == null ) {
result = new ArrayList<ForeignKey>();
}
result.add( fk );
}
}
return result;
}


@Override
public PrimaryKey getPrimaryKey() {
return primaryKey;
Expand Down
Expand Up @@ -86,6 +86,7 @@ public Iterable<Index> getIndexes() {
return indexes.values();
}

@Override
public Index getOrCreateIndex(String name) {
if( indexes.containsKey( name ) ){
return indexes.get( name );
Expand All @@ -100,6 +101,7 @@ public Iterable<UniqueKey> getUniqueKeys() {
return uniqueKeys.values();
}

@Override
public UniqueKey getOrCreateUniqueKey(String name) {
if( uniqueKeys.containsKey( name ) ){
return uniqueKeys.get( name );
Expand All @@ -109,6 +111,7 @@ public UniqueKey getOrCreateUniqueKey(String name) {
return uniqueKey;
}


@Override
public Iterable<CheckConstraint> getCheckConstraints() {
return checkConstraints;
Expand Down

0 comments on commit a096b1c

Please sign in to comment.