コード例 #1
0
  @Override
  protected final void checkValue(
      final Collection<JsonPointer> pointers,
      final ProcessingReport report,
      final JsonSchemaTree tree)
      throws ProcessingException {
    final JsonNode node = getNode(tree);
    final Map<String, JsonNode> map = Maps.newTreeMap();
    map.putAll(JacksonUtils.asMap(node));

    String key;
    JsonNode value;

    for (final Map.Entry<String, JsonNode> entry : map.entrySet()) {
      key = entry.getKey();
      value = entry.getValue();
      if (value.isObject()) pointers.add(BASE_POINTER.append(key));
      else checkDependency(report, entry.getKey(), tree);
    }
  }
コード例 #2
0
public abstract class DependenciesSyntaxChecker extends AbstractSyntaxChecker {
  private static final JsonPointer BASE_POINTER = JsonPointer.empty().append("dependencies");

  protected static final Equivalence<JsonNode> EQUIVALENCE = JsonSchemaEquivalence.getInstance();

  protected final EnumSet<NodeType> dependencyTypes;

  protected DependenciesSyntaxChecker(final NodeType... depTypes) {
    super("dependencies", NodeType.OBJECT);
    dependencyTypes = EnumSet.of(NodeType.OBJECT, depTypes);
  }

  @Override
  protected final void checkValue(
      final Collection<JsonPointer> pointers,
      final ProcessingReport report,
      final JsonSchemaTree tree)
      throws ProcessingException {
    final JsonNode node = getNode(tree);
    final Map<String, JsonNode> map = Maps.newTreeMap();
    map.putAll(JacksonUtils.asMap(node));

    String key;
    JsonNode value;

    for (final Map.Entry<String, JsonNode> entry : map.entrySet()) {
      key = entry.getKey();
      value = entry.getValue();
      if (value.isObject()) pointers.add(BASE_POINTER.append(key));
      else checkDependency(report, entry.getKey(), tree);
    }
  }

  protected abstract void checkDependency(
      final ProcessingReport report, final String name, final JsonSchemaTree tree)
      throws ProcessingException;
}