@Override public void visit(TreatExpression expression) { boolean handled = false; if (expression.getExpression() instanceof PathExpression) { PathExpression treatPath = (PathExpression) expression.getExpression(); if (treatPath.getExpressions().size() == 1 && skipBaseNodeAlias.equals(treatPath.getExpressions().get(0).toString())) { // When we encounter a naked root treat like "TREAT(alias AS Subtype)" we always skip it handled = true; } } if (!handled) { expression.getExpression().accept(this); } EntityType<?> type = metamodel.getEntity(expression.getType()); // TODO: should we check if the type is actually a sub- or super type? currentPosition.setCurrentType(type); currentPosition.setValueType(type); }
@Override public void visit(TreatExpression expression) { boolean handled = false; if (expression.getExpression() instanceof PathExpression) { PathExpression treatPath = (PathExpression) expression.getExpression(); if (treatPath.getExpressions().size() == 1 && skipBaseNodeAlias.equals(treatPath.getExpressions().get(0).toString())) { // When we encounter a naked root treat like "TREAT(alias AS Subtype)" we always skip it handled = true; } } if (!handled) { expression.getExpression().accept(this); } EntityType<?> type = metamodel.getEntity(expression.getType()); // TODO: should we check if the type is actually a sub- or super type? currentPosition.setCurrentType(type); currentPosition.setValueType(type); }
@Override public void visit(ListIndexExpression expression) { expression.getPath().accept(this); Class<?> type = currentPosition.getRealCurrentClass(); if (!List.class.isAssignableFrom(type)) { invalid(expression, "Does not resolve to java.util.List!"); } else { currentPosition.setAttribute(new ListIndexAttribute<>((ListAttribute<?, ?>) currentPosition.getAttribute())); currentPosition.setValueType(null); currentPosition.setKeyType(metamodel.type(Integer.class)); } }
currentPosition.setValueType(valueType); currentPosition.setKeyType(keyType);
currentPosition.setValueType(valueType); currentPosition.setKeyType(keyType);
@Override public void visit(MapKeyExpression expression) { expression.getPath().accept(this); currentPosition.setAttribute(new MapKeyAttribute<>((MapAttribute<?, Object, ?>) currentPosition.getAttribute())); currentPosition.setValueType(null); }
@Override public void visit(MapKeyExpression expression) { expression.getPath().accept(this); currentPosition.setAttribute(new MapKeyAttribute<>((MapAttribute<?, Object, ?>) currentPosition.getAttribute())); currentPosition.setValueType(null); }
@Override public void visit(ListIndexExpression expression) { expression.getPath().accept(this); Class<?> type = currentPosition.getRealCurrentClass(); if (!List.class.isAssignableFrom(type)) { invalid(expression, "Does not resolve to java.util.List!"); } else { currentPosition.setAttribute(new ListIndexAttribute<>((ListAttribute<?, ?>) currentPosition.getAttribute())); currentPosition.setValueType(null); currentPosition.setKeyType(metamodel.type(Integer.class)); } }