@Override public boolean isTokenDefinite() { // in case of leaf multiprops will be merged, so it's kinda definite return singlePropertyCase() || multiPropertyMergeCase(); }
@Override public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { // Can't assert it in ctor because isLeaf() could be changed later on. assert onlyOneIsTrueNonThrow(singlePropertyCase(), multiPropertyMergeCase(), multiPropertyIterationCase()); if (!ctx.jsonProvider().isMap(model)) { if (! isUpstreamDefinite()) { return; } else { String m = model == null ? "null" : model.getClass().getName(); throw new PathNotFoundException(String.format( "Expected to find an object with property %s in path %s but found '%s'. " + "This is not a json object according to the JsonProvider: '%s'.", getPathFragment(), currentPath, m, ctx.configuration().jsonProvider().getClass().getName())); } } if (singlePropertyCase() || multiPropertyMergeCase()) { handleObjectProperty(currentPath, model, ctx, properties); return; } assert multiPropertyIterationCase(); final List<String> currentlyHandledProperty = new ArrayList<String>(1); currentlyHandledProperty.add(null); for (final String property : properties) { currentlyHandledProperty.set(0, property); handleObjectProperty(currentPath, model, ctx, currentlyHandledProperty); } }
@Override public boolean isTokenDefinite() { // in case of leaf multiprops will be merged, so it's kinda definite return singlePropertyCase() || multiPropertyMergeCase(); }
@Override public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { // Can't assert it in ctor because isLeaf() could be changed later on. assert onlyOneIsTrueNonThrow(singlePropertyCase(), multiPropertyMergeCase(), multiPropertyIterationCase()); if (!ctx.jsonProvider().isMap(model)) { if (! isUpstreamDefinite()) { return; } else { String m = model == null ? "null" : model.getClass().getName(); throw new PathNotFoundException(String.format( "Expected to find an object with property %s in path %s but found '%s'. " + "This is not a json object according to the JsonProvider: '%s'.", getPathFragment(), currentPath, m, ctx.configuration().jsonProvider().getClass().getName())); } } if (singlePropertyCase() || multiPropertyMergeCase()) { handleObjectProperty(currentPath, model, ctx, properties); return; } assert multiPropertyIterationCase(); final List<String> currentlyHandledProperty = new ArrayList<String>(1); currentlyHandledProperty.add(null); for (final String property : properties) { currentlyHandledProperty.set(0, property); handleObjectProperty(currentPath, model, ctx, currentlyHandledProperty); } }
@Override public boolean isTokenDefinite() { // in case of leaf multiprops will be merged, so it's kinda definite return singlePropertyCase() || multiPropertyMergeCase(); }
@Override public void evaluate(String currentPath, PathRef parent, Object model, EvaluationContextImpl ctx) { // Can't assert it in ctor because isLeaf() could be changed later on. assert onlyOneIsTrueNonThrow(singlePropertyCase(), multiPropertyMergeCase(), multiPropertyIterationCase()); if (!ctx.jsonProvider().isMap(model)) { if (! isUpstreamDefinite()) { return; } else { String m = model == null ? "null" : model.getClass().getName(); throw new PathNotFoundException(String.format( "Expected to find an object with property %s in path %s but found '%s'. " + "This is not a json object according to the JsonProvider: '%s'.", getPathFragment(), currentPath, m, ctx.configuration().jsonProvider().getClass().getName())); } } if (singlePropertyCase() || multiPropertyMergeCase()) { handleObjectProperty(currentPath, model, ctx, properties); return; } assert multiPropertyIterationCase(); final List<String> currentlyHandledProperty = new ArrayList<String>(1); currentlyHandledProperty.add(null); for (final String property : properties) { currentlyHandledProperty.set(0, property); handleObjectProperty(currentPath, model, ctx, currentlyHandledProperty); } }