@Override public Node apply(Node tree) { List<Phase> phases = Arrays.asList( // includePhase, ramlFragmentsValidator, grammarPhase, referenceCheck, resourcePhase, duplicatedPaths, checkUnusedParameters, annotationValidationPhase, mediaTypeInjection, grammarPhase, schemaValidationPhase, typeValidationPhase, exampleValidationPhase ); Node node = null; for (Phase phase : phases) { node = phase.apply(tree); List<ErrorNode> descendantsWith = node.findDescendantsWith(ErrorNode.class); if (descendantsWith.size() != 0) { throw new ModelBuilderException(descendantsWith); } } return node; } };
public static <T> T buildModel(ModelBindingConfiguration binding, Node node, Class<T> cls) { NodeModelFactory fac = binding.bindingOf(cls); NodeModel model = fac.create(node); T m = ModelProxyBuilder.createModel(cls, model, binding); final Phase grammarPhase = createPhases(new ResourceLoader() { @Nullable @Override public InputStream fetchResource(String resourceName) { return null; } }, new RamlHeader(RAML_10, Default).getFragment()); Node newNode = ((NodeModel) m).getNode(); grammarPhase.apply(newNode); List<ErrorNode> errors = node.findDescendantsWith(ErrorNode.class); if (!errors.isEmpty()) { throw new ModelBuilderException(errors); } return m; }
List<ErrorNode> descendantsWith = node.findDescendantsWith(ErrorNode.class); if (descendantsWith.size() != 0) { throw new ModelBuilderException(descendantsWith);