public class NameService extends Object
This service provides vendor-aware and type-aware name comparison utilities, replacing scattered string comparisons throughout GSP with a unified approach.
Key responsibilities:
Design: This service delegates to NamePolicyFactory for matcher instances
and preserves TSQLEnv.normalizeIdentifier(gudusoft.gsqlparser.sqlenv.ESQLDataObjectType, java.lang.String) as the authority for identifier
quoting and default-case normalization.
| 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 that uses vendor/type-aware name matching for equality.
|
List<String> |
distinctCopy(ESQLDataObjectType type,
Iterable<String> names)
Creates a distinct copy of a collection, removing duplicates using vendor/type-aware matching.
|
boolean |
equals(ESQLDataObjectType type,
String name1,
String name2)
Checks if two names are equal according to vendor-specific and type-specific rules.
|
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, using vendor/type-aware matching.
|
boolean |
isCaseSensitive(ESQLDataObjectType type)
Checks if a specific object type is case-sensitive for this vendor.
|
public NameService(EDbVendor vendor)
vendor - the database vendorpublic EDbVendor getVendor()
public boolean equals(ESQLDataObjectType type, String name1, String name2)
This method replaces TSQLEnv.compareIdentifier() with a more robust
implementation backed by SqlNameMatcher framework.
Names are normalized using GSP's existing rules before matching.
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. For example, with case-insensitive matching:
["foo", "FOO", "bar", "Bar"] → ["foo", "bar"]
type - the SQL object typenames - the collection of names (may contain duplicates)public Set<String> createSet(ESQLDataObjectType type)
The returned Set will treat names as equal if they match according to the vendor's case sensitivity rules for the specified object type.
Implementation note: Uses a wrapper around LinkedHashSet that normalizes keys before insertion/lookup.
type - the SQL object typepublic boolean isCaseSensitive(ESQLDataObjectType type)
Convenience method that delegates to NamePolicyFactory.
type - the object type