use of org.everit.json.schema.CombinedSchema in project nakadi by zalando.
the class SchemaDiff method recursiveCheck.
static void recursiveCheck(final Schema originalIn, final Schema updateIn, final SchemaDiffState state) {
if (originalIn == null && updateIn == null) {
return;
}
if (updateIn == null) {
state.addChange(SCHEMA_REMOVED);
return;
}
final Schema original;
final Schema update;
if (!originalIn.getClass().equals(updateIn.getClass())) {
// Tricky part. EmptySchema is the same as an empty ObjectSchema.
if (originalIn instanceof EmptySchema && updateIn instanceof ObjectSchema) {
original = replaceWithEmptyObjectSchema(originalIn);
update = updateIn;
} else {
state.addChange(TYPE_CHANGED);
return;
}
} else {
original = originalIn;
update = updateIn;
}
state.analyzeSchema(originalIn, () -> {
if (!Objects.equals(original.getId(), update.getId())) {
state.addChange(ID_CHANGED);
}
if (!Objects.equals(original.getTitle(), update.getTitle())) {
state.addChange(TITLE_CHANGED);
}
if (!Objects.equals(original.getDescription(), update.getDescription())) {
state.addChange(DESCRIPTION_CHANGED);
}
if (original instanceof StringSchema) {
StringSchemaDiff.recursiveCheck((StringSchema) original, (StringSchema) update, state);
} else if (original instanceof NumberSchema) {
NumberSchemaDiff.recursiveCheck((NumberSchema) original, (NumberSchema) update, state);
} else if (original instanceof EnumSchema) {
EnumSchemaDiff.recursiveCheck((EnumSchema) original, (EnumSchema) update, state);
} else if (original instanceof CombinedSchema) {
CombinedSchemaDiff.recursiveCheck((CombinedSchema) original, (CombinedSchema) update, state);
} else if (original instanceof ObjectSchema) {
ObjectSchemaDiff.recursiveCheck((ObjectSchema) original, (ObjectSchema) update, state);
} else if (original instanceof ArraySchema) {
ArraySchemaDiff.recursiveCheck((ArraySchema) original, (ArraySchema) update, state);
} else if (original instanceof ReferenceSchema) {
ReferenceSchemaDiff.recursiveCheck((ReferenceSchema) original, (ReferenceSchema) update, state);
}
});
}
Aggregations