All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tigrisdata.tools.validation.FieldRemovedRule Maven / Gradle / Ivy

There is a newer version: 1.0.0-alpha.3
Show newest version
package com.tigrisdata.tools.validation;

import com.google.gson.JsonObject;

import java.util.HashSet;
import java.util.Set;

public class FieldRemovedRule implements ValidationRule {
  private static final String PROPERTIES = "properties";

  @Override
  public void validate(JsonObject beforeSchema, JsonObject afterSchema) throws ValidationException {
    Set beforeKeys = new HashSet<>(beforeSchema.getAsJsonObject(PROPERTIES).keySet());
    Set afterKeys = new HashSet<>(afterSchema.getAsJsonObject(PROPERTIES).keySet());
    for (String beforeKey : beforeKeys) {
      if (!afterKeys.contains(beforeKey)) {
        throw new ValidationException(
            "property name=" + beforeKey + ", is not present in newer version");
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy