Case-insensitive Discovery message type names#1956
Case-insensitive Discovery message type names#1956andreamlin merged 23 commits intogoogleapis:masterfrom
Conversation
|
PTAL |
Codecov Report
@@ Coverage Diff @@
## master #1956 +/- ##
============================================
- Coverage 86.01% 85.94% -0.08%
- Complexity 4933 4949 +16
============================================
Files 452 452
Lines 19655 19719 +64
Branches 2055 2076 +21
============================================
+ Hits 16906 16947 +41
- Misses 2065 2076 +11
- Partials 684 696 +12
Continue to review full report at Codecov.
|
| private final Schema originalSchema; | ||
| private final DiscoApiModel apiModel; | ||
|
|
||
| // Unformatted type name for this Field. For message-type Fields, this will be globally unique. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| public abstract String httpMethod(); | ||
|
|
||
| /** @return the ID. */ | ||
| /** @return the ID. This is unique. */ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| @Override | ||
| public String getNicknameFor(Schema type) { | ||
| public String getNicknameFor(DiscoveryField type) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
6d505d4 to
efe3df9
Compare
|
Made adjustments. PTAL |
| * content but different parents will still have different hashCodes. | ||
| */ | ||
| @Override | ||
| public int hashCode() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| .compareTo(o2.getValue().getDefaultPackageName()); | ||
| } | ||
| }; | ||
| private static Map<Map.Entry<Schema, DiscoApiModel>, DiscoveryField> globalObjects = |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
FIXED things. PTAL |
| if (isTopLevelSchema(schema)) { | ||
| // Within this namespace, get a unique name for this message-type schema. | ||
| SchemaNamer messageNamer; | ||
| if (namespaceToSchemaNamer.containsKey(namespace)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| Preconditions.checkNotNull(schema); | ||
| Preconditions.checkNotNull(rootApiModel); | ||
| return new DiscoveryField(schema, rootApiModel); | ||
| public static synchronized DiscoveryField create(Schema schema, DiscoApiModel rootApiModel) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| private Map<Schema, String> messageNames = new TreeMap<>(messageSchemaComparator); | ||
|
|
||
| String getSchemaName(Schema schema, String basename) { | ||
| if (messageNames.containsKey(schema)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return Objects.equals( | ||
| getApiModel().getDefaultPackageName(), | ||
| (otherModelData.getApiModel().getDefaultPackageName())) | ||
| && getSchema().hashCode() == otherModelData.getSchema().hashCode(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * content but different parents will still have different hashCodes. | ||
| */ | ||
| @Override | ||
| public int hashCode() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * @param comparator function to determine equality on Strings | ||
| */ | ||
| public SymbolTable(Comparator<String> comparator) { | ||
| symbolTable = new ConcurrentSkipListSet<>(comparator); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Made fixes. PTAL |
90cb03e to
9acfd63
Compare
| * content but different parents will still have different hashCodes. | ||
| */ | ||
| @Override | ||
| public int hashCode() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Windows NTFS is case-insensitive, so this PR escapes DiscoveryField identifiers that are the same, disregarding character casing.
Introduce global table of DiscoveryFields to prevent duplicate creation of DiscoveryFields from the same Schema.
Constructor for DiscoveryFields enforces unique, case-insensitive identifiers for message-type Schemas.
Refactor SchemaTypeName* utils to use DiscoveryFields instead of Schemas. This allows the TypeName utils to use the DiscoveryField's unique identifiers.