public class NameService extends Object
Equality delegates to IdentifierService.areEqualStatic(gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String) and the set/dedup
utilities key by CanonKey, so every operation here observes exactly the same
relation as SQLUtil.sameName / TSQLEnv.compareIdentifier. The previous
implementation routed through the SqlNameMatcher framework configured from the legacy
per-type case booleans, which collapsed quoted-case distinctions the canonical rules
preserve (e.g. BigQuery tables, Couchbase).
| Constructor and Description |
|---|
NameService(EDbVendor vendor)
Creates a new NameService for the specified database vendor.
|
| Modifier and Type | Method and Description |
|---|---|
Set<String> |
createSet(ESQLDataObjectType type)
Creates a Set whose membership follows canonical name equality: names are the
same element iff their
CanonKeys are equal. |
List<String> |
distinctCopy(ESQLDataObjectType type,
Iterable<String> names)
Creates a distinct copy of a collection, removing canonical duplicates.
|
boolean |
equals(ESQLDataObjectType type,
String name1,
String name2)
Checks if two names are equal under the canonical identifier-equality relation
(
IdentifierService.areEqualStatic(gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String)) for this vendor and object type. |
EDbVendor |
getVendor()
Returns the database vendor associated with this service.
|
int |
indexOf(ESQLDataObjectType type,
Iterable<String> names,
String target)
Finds the index of a name in a collection under canonical equality.
|
boolean |
isCaseSensitive(ESQLDataObjectType type)
Whether the UNQUOTED comparison policy for this object type is case-sensitive.
|
public NameService(EDbVendor vendor)
vendor - the database vendorpublic EDbVendor getVendor()
public boolean equals(ESQLDataObjectType type, String name1, String name2)
IdentifierService.areEqualStatic(gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String, java.lang.String)) for this vendor and object type.type - the SQL object type (table, column, function, etc.)name1 - the first name to comparename2 - the second name to comparepublic int indexOf(ESQLDataObjectType type, Iterable<String> names, String target)
This is a case-aware version of List.indexOf().
type - the SQL object typenames - the collection of names to searchtarget - the name to findpublic List<String> distinctCopy(ESQLDataObjectType type, Iterable<String> names)
Preserves insertion order and the first spelling seen. For example, for a case-insensitive domain:
["foo", "FOO", "bar", "Bar"] → ["foo", "bar"]
type - the SQL object typenames - the collection of names (may contain duplicates)public Set<String> createSet(ESQLDataObjectType type)
CanonKeys are equal.type - the SQL object typepublic boolean isCaseSensitive(ESQLDataObjectType type)
Quoted operands may follow a different rule (quoted-case-preserving vendors); this describes only the unquoted policy from the vendor's identifier rules.
type - the object type