@Override public synchronized SchemaEntry registerIfLatest(String schema, SchemaEntry latest) throws SchemaValidationException { if (latest == this.latest || (latest != null && latest.equals(this.latest))) { return register(schema); } else { return null; } }
@Override public synchronized SchemaEntry registerIfLatest(String schema, SchemaEntry latest) throws SchemaValidationException { if (latest == this.latest || (latest != null && latest.equals(this.latest))) { return register(schema); } else { return null; } }
@Override public synchronized SchemaEntry registerIfLatest(String schema, SchemaEntry latest) throws SchemaValidationException { isValid(); if (latest == this.latest // both null || (latest != null && latest.equals(this.latest))) { return register(schema); } else { return null; } }
@Override public synchronized SchemaEntry registerIfLatest(String schema, SchemaEntry latest) throws SchemaValidationException { isValid(); if (latest == this.latest // both null || (latest != null && latest.equals(this.latest))) { return register(schema); } else { return null; } }
/** * Register the provided schema only if the current latest schema matches the * provided latest entry. * * @param schema The schema to register * @param latest the entry that must match the current actual latest value in order * to register this schema. * @return The id of the schema, or null if latest does not match. * @throws org.schemarepo.SchemaValidationException * If the schema change is not valid according the validation rules * of the subject */ @Override public SchemaEntry registerIfLatest(String schema, SchemaEntry latest) throws SchemaValidationException { SchemaEntry latestInZk = latest(); if (latest == latestInZk // both null || (latest != null && latest.equals(latestInZk))) { return register(schema); } else { return null; } }
@Override public SchemaEntry registerIfLatest(String schema, SchemaEntry latest) throws SchemaValidationException { Iterable<SchemaEntry> schemaEntries = allEntries(); SchemaEntry actualLatest = null; for (SchemaEntry entry : schemaEntries) { actualLatest = entry; break; } if (actualLatest == latest || ((actualLatest != null) && actualLatest.equals(latest))) { // they are equal, either both are null or they equal validator.validate(schema, schemaEntries); return super.registerIfLatest(schema, latest); } else { return null; } } }
@Override public SchemaEntry registerIfLatest(String schema, SchemaEntry latest) throws SchemaValidationException { Iterable<SchemaEntry> schemaEntries = allEntries(); SchemaEntry actualLatest = null; for (SchemaEntry entry : schemaEntries) { actualLatest = entry; break; } if (actualLatest == latest || ((actualLatest != null) && actualLatest.equals(latest))) { // they are equal, either both are null or they equal validator.validate(schema, schemaEntries); return super.registerIfLatest(schema, latest); } else { return null; } } }
@Test public void testEqualsAndHashCode() { SchemaEntry entry = new SchemaEntry("id", "schema"); SchemaEntry entry2 = new SchemaEntry("id", "schema"); SchemaEntry nullId = new SchemaEntry(null, "schema"); SchemaEntry nullSchema = new SchemaEntry("id", null); SchemaEntry idDiffers = new SchemaEntry("iddd", "schema"); SchemaEntry sDiffers = new SchemaEntry("id", "schemaaaa"); SchemaEntry allNull = new SchemaEntry(null, null); SchemaEntry allNull2 = new SchemaEntry(null, null); Assert.assertEquals(entry, entry); Assert.assertEquals(entry, entry2); Assert.assertEquals(entry2, entry); Assert.assertEquals(entry.hashCode(), entry2.hashCode()); Assert.assertFalse(entry.equals(null)); Assert.assertFalse(entry.equals(new Object())); Assert.assertFalse(entry.equals(nullId)); Assert.assertFalse(nullId.equals(entry)); Assert.assertFalse(entry.equals(nullSchema)); Assert.assertFalse(nullSchema.equals(entry)); Assert.assertFalse(entry.equals(idDiffers)); Assert.assertFalse(idDiffers.equals(entry)); Assert.assertFalse(entry.equals(sDiffers)); Assert.assertFalse(sDiffers.equals(entry)); Assert.assertEquals(allNull, allNull2); Assert.assertEquals(allNull.hashCode(), allNull2.hashCode()); }
boolean foundfoo = false; for (SchemaEntry s : readOnlySubject.allEntries()) { if (s.equals(foo)) { foundfoo = true;