diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java index 89f00cf0dc056..8dc617116655c 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/ShardingSphereMetaData.java @@ -27,7 +27,7 @@ import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase; import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData; -import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier; +import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier; import org.apache.shardingsphere.infra.rule.ShardingSphereRule; import org.apache.shardingsphere.infra.rule.attribute.datasource.StaticDataSourceRuleAttribute; import org.apache.shardingsphere.infra.rule.scope.GlobalRule; @@ -48,7 +48,7 @@ public final class ShardingSphereMetaData { @Getter(AccessLevel.NONE) - private final Map databases; + private final Map databases; private final ResourceMetaData globalResourceMetaData; @@ -64,7 +64,7 @@ public ShardingSphereMetaData() { public ShardingSphereMetaData(final Collection databases, final ResourceMetaData globalResourceMetaData, final RuleMetaData globalRuleMetaData, final ConfigurationProperties props) { - this.databases = new ConcurrentHashMap<>(databases.stream().collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each))); + this.databases = new ConcurrentHashMap<>(databases.stream().collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each))); this.globalResourceMetaData = globalResourceMetaData; this.globalRuleMetaData = globalRuleMetaData; this.props = props; @@ -87,7 +87,7 @@ public Collection getAllDatabases() { * @return contains database from meta data or not */ public boolean containsDatabase(final String databaseName) { - return databases.containsKey(new ShardingSphereMetaDataIdentifier(databaseName)); + return databases.containsKey(new ShardingSphereIdentifier(databaseName)); } /** @@ -97,7 +97,7 @@ public boolean containsDatabase(final String databaseName) { * @return meta data database */ public ShardingSphereDatabase getDatabase(final String databaseName) { - return databases.get(new ShardingSphereMetaDataIdentifier(databaseName)); + return databases.get(new ShardingSphereIdentifier(databaseName)); } /** @@ -109,7 +109,7 @@ public ShardingSphereDatabase getDatabase(final String databaseName) { */ public void addDatabase(final String databaseName, final DatabaseType protocolType, final ConfigurationProperties props) { ShardingSphereDatabase database = ShardingSphereDatabase.create(databaseName, protocolType, props); - databases.put(new ShardingSphereMetaDataIdentifier(database.getName()), database); + databases.put(new ShardingSphereIdentifier(database.getName()), database); globalRuleMetaData.getRules().forEach(each -> ((GlobalRule) each).refresh(databases.values(), GlobalRuleChangedType.DATABASE_CHANGED)); } @@ -119,7 +119,7 @@ public void addDatabase(final String databaseName, final DatabaseType protocolTy * @param database database */ public void putDatabase(final ShardingSphereDatabase database) { - databases.put(new ShardingSphereMetaDataIdentifier(database.getName()), database); + databases.put(new ShardingSphereIdentifier(database.getName()), database); } /** @@ -128,7 +128,7 @@ public void putDatabase(final ShardingSphereDatabase database) { * @param databaseName database name */ public void dropDatabase(final String databaseName) { - cleanResources(databases.remove(new ShardingSphereMetaDataIdentifier(databaseName))); + cleanResources(databases.remove(new ShardingSphereIdentifier(databaseName))); } @SneakyThrows(Exception.class) diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java index f78c5c6f7961d..8233629431e55 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/ShardingSphereDatabase.java @@ -32,7 +32,7 @@ import org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilderMaterial; import org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilder; import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema; -import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier; +import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier; import org.apache.shardingsphere.infra.rule.ShardingSphereRule; import org.apache.shardingsphere.infra.rule.attribute.datanode.MutableDataNodeRuleAttribute; import org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder; @@ -62,7 +62,7 @@ public final class ShardingSphereDatabase { private final RuleMetaData ruleMetaData; @Getter(AccessLevel.NONE) - private final Map schemas; + private final Map schemas; public ShardingSphereDatabase(final String name, final DatabaseType protocolType, final ResourceMetaData resourceMetaData, final RuleMetaData ruleMetaData, final Collection schemas) { @@ -70,7 +70,7 @@ public ShardingSphereDatabase(final String name, final DatabaseType protocolType this.protocolType = protocolType; this.resourceMetaData = resourceMetaData; this.ruleMetaData = ruleMetaData; - this.schemas = new ConcurrentHashMap<>(schemas.stream().collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each))); + this.schemas = new ConcurrentHashMap<>(schemas.stream().collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each))); } /** @@ -142,7 +142,7 @@ public Collection getAllSchemas() { * @return contains schema from database or not */ public boolean containsSchema(final String schemaName) { - return schemas.containsKey(new ShardingSphereMetaDataIdentifier(schemaName)); + return schemas.containsKey(new ShardingSphereIdentifier(schemaName)); } /** @@ -152,7 +152,7 @@ public boolean containsSchema(final String schemaName) { * @return schema */ public ShardingSphereSchema getSchema(final String schemaName) { - return schemas.get(new ShardingSphereMetaDataIdentifier(schemaName)); + return schemas.get(new ShardingSphereIdentifier(schemaName)); } /** @@ -161,7 +161,7 @@ public ShardingSphereSchema getSchema(final String schemaName) { * @param schema schema */ public void addSchema(final ShardingSphereSchema schema) { - schemas.put(new ShardingSphereMetaDataIdentifier(schema.getName()), schema); + schemas.put(new ShardingSphereIdentifier(schema.getName()), schema); } /** @@ -170,7 +170,7 @@ public void addSchema(final ShardingSphereSchema schema) { * @param schemaName schema name */ public void dropSchema(final String schemaName) { - schemas.remove(new ShardingSphereMetaDataIdentifier(schemaName)); + schemas.remove(new ShardingSphereIdentifier(schemaName)); } /** diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java index 13532c699e989..0af5f4b04b182 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereSchema.java @@ -18,7 +18,7 @@ package org.apache.shardingsphere.infra.metadata.database.schema.model; import lombok.Getter; -import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier; +import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier; import java.util.Collection; import java.util.Collections; @@ -34,9 +34,9 @@ public final class ShardingSphereSchema { @Getter private final String name; - private final Map tables; + private final Map tables; - private final Map views; + private final Map views; @SuppressWarnings("CollectionWithoutInitialCapacity") public ShardingSphereSchema(final String name) { @@ -49,8 +49,8 @@ public ShardingSphereSchema(final String name, final Collection(tables.size(), 1F); this.views = new ConcurrentHashMap<>(views.size(), 1F); - tables.forEach(each -> this.tables.put(new ShardingSphereMetaDataIdentifier(each.getName()), each)); - views.forEach(each -> this.views.put(new ShardingSphereMetaDataIdentifier(each.getName()), each)); + tables.forEach(each -> this.tables.put(new ShardingSphereIdentifier(each.getName()), each)); + views.forEach(each -> this.views.put(new ShardingSphereIdentifier(each.getName()), each)); } /** @@ -69,7 +69,7 @@ public Collection getAllTables() { * @return contains table or not */ public boolean containsTable(final String tableName) { - return tables.containsKey(new ShardingSphereMetaDataIdentifier(tableName)); + return tables.containsKey(new ShardingSphereIdentifier(tableName)); } /** @@ -79,7 +79,7 @@ public boolean containsTable(final String tableName) { * @return table */ public ShardingSphereTable getTable(final String tableName) { - return tables.get(new ShardingSphereMetaDataIdentifier(tableName)); + return tables.get(new ShardingSphereIdentifier(tableName)); } /** @@ -88,7 +88,7 @@ public ShardingSphereTable getTable(final String tableName) { * @param table table */ public void putTable(final ShardingSphereTable table) { - tables.put(new ShardingSphereMetaDataIdentifier(table.getName()), table); + tables.put(new ShardingSphereIdentifier(table.getName()), table); } /** @@ -97,7 +97,7 @@ public void putTable(final ShardingSphereTable table) { * @param tableName table name */ public void removeTable(final String tableName) { - tables.remove(new ShardingSphereMetaDataIdentifier(tableName)); + tables.remove(new ShardingSphereIdentifier(tableName)); } /** @@ -116,7 +116,7 @@ public Collection getAllViews() { * @return contains view or not */ public boolean containsView(final String viewName) { - return views.containsKey(new ShardingSphereMetaDataIdentifier(viewName)); + return views.containsKey(new ShardingSphereIdentifier(viewName)); } /** @@ -126,7 +126,7 @@ public boolean containsView(final String viewName) { * @return view */ public ShardingSphereView getView(final String viewName) { - return views.get(new ShardingSphereMetaDataIdentifier(viewName)); + return views.get(new ShardingSphereIdentifier(viewName)); } /** @@ -135,7 +135,7 @@ public ShardingSphereView getView(final String viewName) { * @param view view */ public void putView(final ShardingSphereView view) { - views.put(new ShardingSphereMetaDataIdentifier(view.getName()), view); + views.put(new ShardingSphereIdentifier(view.getName()), view); } /** @@ -144,7 +144,7 @@ public void putView(final ShardingSphereView view) { * @param viewName view name */ public void removeView(final String viewName) { - views.remove(new ShardingSphereMetaDataIdentifier(viewName)); + views.remove(new ShardingSphereIdentifier(viewName)); } /** diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java index bfd15c84d365b..ee34246c6a22e 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java @@ -23,7 +23,7 @@ import lombok.Getter; import lombok.ToString; import org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType; -import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDataIdentifier; +import org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereIdentifier; import java.util.ArrayList; import java.util.Collection; @@ -43,7 +43,7 @@ public final class ShardingSphereTable { private final String name; @Getter(AccessLevel.NONE) - private final Map columns; + private final Map columns; private final List columnNames = new ArrayList<>(); @@ -54,10 +54,10 @@ public final class ShardingSphereTable { private final Map visibleColumnAndIndexMap = new CaseInsensitiveMap<>(); @Getter(AccessLevel.NONE) - private final Map indexes; + private final Map indexes; @Getter(AccessLevel.NONE) - private final Map constraints; + private final Map constraints; private final TableType type; @@ -75,11 +75,11 @@ public ShardingSphereTable(final String name, final Collection createColumns(final Collection columns) { - Map result = new LinkedHashMap<>(columns.size(), 1F); + private Map createColumns(final Collection columns) { + Map result = new LinkedHashMap<>(columns.size(), 1F); int index = 0; for (ShardingSphereColumn each : columns) { - result.put(new ShardingSphereMetaDataIdentifier(each.getName()), each); + result.put(new ShardingSphereIdentifier(each.getName()), each); columnNames.add(each.getName()); if (each.isPrimaryKey()) { primaryKeyColumns.add(each.getName()); @@ -92,13 +92,13 @@ private Map createColumn return result; } - private Map createIndexes(final Collection indexes) { - return indexes.stream().collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(indexes.size(), 1F))); + private Map createIndexes(final Collection indexes) { + return indexes.stream().collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(indexes.size(), 1F))); } - private Map createConstraints(final Collection constraints) { + private Map createConstraints(final Collection constraints) { return constraints.stream() - .collect(Collectors.toMap(each -> new ShardingSphereMetaDataIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(constraints.size(), 1F))); + .collect(Collectors.toMap(each -> new ShardingSphereIdentifier(each.getName()), each -> each, (a, b) -> b, () -> new LinkedHashMap<>(constraints.size(), 1F))); } /** @@ -108,7 +108,7 @@ private Map createCo * @return contains column or not */ public boolean containsColumn(final String columnName) { - return null != columnName && columns.containsKey(new ShardingSphereMetaDataIdentifier(columnName)); + return null != columnName && columns.containsKey(new ShardingSphereIdentifier(columnName)); } /** @@ -118,7 +118,7 @@ public boolean containsColumn(final String columnName) { * @return column */ public ShardingSphereColumn getColumn(final String columnName) { - return columns.get(new ShardingSphereMetaDataIdentifier(columnName)); + return columns.get(new ShardingSphereIdentifier(columnName)); } /** @@ -137,7 +137,7 @@ public Collection getAllColumns() { * @return contains index or not */ public boolean containsIndex(final String indexName) { - return null != indexName && indexes.containsKey(new ShardingSphereMetaDataIdentifier(indexName)); + return null != indexName && indexes.containsKey(new ShardingSphereIdentifier(indexName)); } /** @@ -155,7 +155,7 @@ public Collection getAllIndexes() { * @param index index */ public void putIndex(final ShardingSphereIndex index) { - indexes.put(new ShardingSphereMetaDataIdentifier(index.getName()), index); + indexes.put(new ShardingSphereIdentifier(index.getName()), index); } /** @@ -164,7 +164,7 @@ public void putIndex(final ShardingSphereIndex index) { * @param indexName index name */ public void removeIndex(final String indexName) { - indexes.remove(new ShardingSphereMetaDataIdentifier(indexName)); + indexes.remove(new ShardingSphereIdentifier(indexName)); } /** diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/DatabaseDialectMetaDataIdentifierHandler.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/DatabaseDialectIdentifierHandler.java similarity index 89% rename from infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/DatabaseDialectMetaDataIdentifierHandler.java rename to infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/DatabaseDialectIdentifierHandler.java index e0cbec7703c14..ed9d0332c91a0 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/DatabaseDialectMetaDataIdentifierHandler.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/DatabaseDialectIdentifierHandler.java @@ -21,10 +21,10 @@ import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI; /** - * Database dialect meta data identifier handler. + * Database dialect identifier handler. */ @SingletonSPI -public interface DatabaseDialectMetaDataIdentifierHandler extends DatabaseTypedSPI { +public interface DatabaseDialectIdentifierHandler extends DatabaseTypedSPI { /** * Whether identifier is case-sensitive. diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/ShardingSphereMetaDataIdentifier.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/ShardingSphereIdentifier.java similarity index 72% rename from infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/ShardingSphereMetaDataIdentifier.java rename to infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/ShardingSphereIdentifier.java index be7be0d442ffe..ea0699c70f1d3 100644 --- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/ShardingSphereMetaDataIdentifier.java +++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/identifier/ShardingSphereIdentifier.java @@ -24,33 +24,33 @@ import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue; /** - * ShardingSphere meta data identifier. + * ShardingSphere identifier. */ -public final class ShardingSphereMetaDataIdentifier { +public final class ShardingSphereIdentifier { private final boolean isCaseSensitive; private final CaseInsensitiveString value; - public ShardingSphereMetaDataIdentifier(final String value) { + public ShardingSphereIdentifier(final String value) { isCaseSensitive = false; this.value = new CaseInsensitiveString(value); } - public ShardingSphereMetaDataIdentifier(final String value, final DatabaseType databaseType) { - isCaseSensitive = DatabaseTypedSPILoader.findService(DatabaseDialectMetaDataIdentifierHandler.class, databaseType) - .map(DatabaseDialectMetaDataIdentifierHandler::isCaseSensitive).orElse(false); + public ShardingSphereIdentifier(final String value, final DatabaseType databaseType) { + isCaseSensitive = DatabaseTypedSPILoader.findService(DatabaseDialectIdentifierHandler.class, databaseType) + .map(DatabaseDialectIdentifierHandler::isCaseSensitive).orElse(false); this.value = new CaseInsensitiveString(value); } - public ShardingSphereMetaDataIdentifier(final IdentifierValue value) { + public ShardingSphereIdentifier(final IdentifierValue value) { isCaseSensitive = QuoteCharacter.NONE != value.getQuoteCharacter(); this.value = new CaseInsensitiveString(value.getValue()); } - public ShardingSphereMetaDataIdentifier(final IdentifierValue value, final DatabaseType databaseType) { + public ShardingSphereIdentifier(final IdentifierValue value, final DatabaseType databaseType) { isCaseSensitive = QuoteCharacter.NONE != value.getQuoteCharacter() - && DatabaseTypedSPILoader.findService(DatabaseDialectMetaDataIdentifierHandler.class, databaseType).map(DatabaseDialectMetaDataIdentifierHandler::isCaseSensitive).orElse(false); + && DatabaseTypedSPILoader.findService(DatabaseDialectIdentifierHandler.class, databaseType).map(DatabaseDialectIdentifierHandler::isCaseSensitive).orElse(false); this.value = new CaseInsensitiveString(value.getValue()); } @@ -65,10 +65,10 @@ public String getValue() { @Override public boolean equals(final Object obj) { - if (!(obj instanceof ShardingSphereMetaDataIdentifier)) { + if (!(obj instanceof ShardingSphereIdentifier)) { return false; } - return isCaseSensitive ? value.toString().equals(((ShardingSphereMetaDataIdentifier) obj).value.toString()) : value.equals(((ShardingSphereMetaDataIdentifier) obj).value); + return isCaseSensitive ? value.toString().equals(((ShardingSphereIdentifier) obj).value.toString()) : value.equals(((ShardingSphereIdentifier) obj).value); } @Override