[#974] Add Schema.getTable(String), getSequence(String), getUDT(String) for better runtime Schema meta-navigation
This commit is contained in:
parent
9ad262e651
commit
79dbdb4d77
@ -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);
|
||||
}
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user