[#974] Add Schema.getTable(String), getSequence(String), getUDT(String) for better runtime Schema meta-navigation

This commit is contained in:
Lukas Eder 2011-12-04 14:21:43 +00:00
parent 9ad262e651
commit 79dbdb4d77
2 changed files with 51 additions and 0 deletions

View File

@ -63,13 +63,31 @@ public interface Schema extends NamedQueryPart {
*/
List<Table<?>> getTables();
/**
* Get a table by its name (case-sensitive) in this schema, or
* <code>null</code> if no such table exists
*/
Table<?> getTable(String name);
/**
* List all UDTs contained in this schema
*/
List<UDT<?>> getUDTs();
/**
* Get a UDT by its name (case-sensitive) in this schema, or
* <code>null</code> if no such UDT exists
*/
UDT<?> getUDT(String name);
/**
* List all sequences contained in this schema
*/
List<Sequence<?>> getSequences();
/**
* Get a sequence by its name (case-sensitive) in this schema, or
* <code>null</code> if no such sequence exists
*/
Sequence<?> getSequence(String name);
}

View File

@ -90,6 +90,39 @@ public class SchemaImpl extends AbstractNamedQueryPart implements Schema {
typeMapping.put(name, type);
}
@Override
public final Table<?> getTable(String name) {
for (Table<?> table : getTables()) {
if (table.getName().equals(name)) {
return table;
}
}
return null;
}
@Override
public final UDT<?> getUDT(String name) {
for (UDT<?> udt : getUDTs()) {
if (udt.getName().equals(name)) {
return udt;
}
}
return null;
}
@Override
public final Sequence<?> getSequence(String name) {
for (Sequence<?> sequence : getSequences()) {
if (sequence.getName().equals(name)) {
return sequence;
}
}
return null;
}
/**
* {@inheritDoc}
* <p>