public Map<Attribute<?, ?>, Type<?>> getPossibleTargets() { Map<Attribute<?, ?>, Type<?>> possibleTargets = new HashMap<>(); List<PathPosition> positions = pathPositions; int size = positions.size(); for (int i = 0; i < size; i++) { PathPosition position = positions.get(i); possibleTargets.put(position.getAttribute(), position.getCurrentType()); } return possibleTargets; }
public Map<Attribute<?, ?>, Type<?>> getPossibleTargets() { Map<Attribute<?, ?>, Type<?>> possibleTargets = new HashMap<>(); List<PathPosition> positions = pathPositions; int size = positions.size(); for (int i = 0; i < size; i++) { PathPosition position = positions.get(i); possibleTargets.put(position.getAttribute(), position.getCurrentType()); } return possibleTargets; }
@Override public void visit(PathExpression expression) { if (currentPosition.getCurrentType() == null) { currentPosition.setCurrentType(expression.getPathReference().getType()); return; } List<PathElementExpression> expressions = expression.getExpressions(); int size = expressions.size(); int i = 0; // Skip the base node in (absolute) path expressions otherwise the resolving will fail if (size > 1) { PathElementExpression firstExpression = expressions.get(0); if (firstExpression instanceof PropertyExpression) { if (((PropertyExpression) firstExpression).getProperty().equals(skipBaseNodeAlias)) { i = 1; } } } for (; i < size; i++) { expressions.get(i).accept(this); } }
@Override public void visit(PropertyExpression expression) { String property = expression.getProperty(); if (currentPosition.getCurrentType() instanceof BasicType<?>) { throw new IllegalArgumentException("Can't access property '" + property + "' on basic type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'. Did you forget to add the embeddable type to your persistence.xml?"); Attribute<?, ?> attribute = JpaMetamodelUtils.getAttribute((ManagedType<?>) currentPosition.getCurrentType(), property); throw new IllegalArgumentException("Attribute '" + property + "' not found on type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'"); Type<?> type = getType(currentPosition.getCurrentType(), attribute); Type<?> valueType = null; Type<?> keyType = null;
@Override public void visit(PropertyExpression expression) { String property = expression.getProperty(); if (currentPosition.getCurrentType() instanceof BasicType<?>) { throw new IllegalArgumentException("Can't access property '" + property + "' on basic type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'. Did you forget to add the embeddable type to your persistence.xml?"); Attribute<?, ?> attribute = JpaMetamodelUtils.getAttribute((ManagedType<?>) currentPosition.getCurrentType(), property); throw new IllegalArgumentException("Attribute '" + property + "' not found on type '" + JpaMetamodelUtils.getTypeName(currentPosition.getCurrentType()) + "'"); Type<?> type = getType(currentPosition.getCurrentType(), attribute); Type<?> valueType = null; Type<?> keyType = null;
@Override public void visit(PathExpression expression) { if (currentPosition.getCurrentType() == null) { currentPosition.setCurrentType(expression.getPathReference().getType()); return; } List<PathElementExpression> expressions = expression.getExpressions(); int size = expressions.size(); int i = 0; // Skip the base node in (absolute) path expressions otherwise the resolving will fail if (size > 1) { PathElementExpression firstExpression = expressions.get(0); if (firstExpression instanceof PropertyExpression) { if (((PropertyExpression) firstExpression).getProperty().equals(skipBaseNodeAlias)) { i = 1; } } } for (; i < size; i++) { expressions.get(i).accept(this); } }
@Override public void visit(ArrayExpression expression) { boolean wasParamsAllowed = parametersAllowed; List<PathPosition> currentPositions = pathPositions; PathPosition position = currentPosition; parametersAllowed = true; pathPositions = new ArrayList<>(); pathPositions.add(currentPosition = new PathPosition(managedType, null)); // Validate index against metamodel expression.getIndex().accept(this); parametersAllowed = wasParamsAllowed; currentPosition = position; pathPositions = currentPositions; // Only need the base to navigate down the path expression.getBase().accept(this); currentPosition.setCurrentType(currentPosition.getCurrentType()); }
public Class<?> getCurrentClass() { return getCurrentType() == null ? null : getCurrentType().getJavaType(); }
public Class<?> getCurrentClass() { return getCurrentType() == null ? null : getCurrentType().getJavaType(); }
@Override public void visit(MapValueExpression expression) { expression.getPath().accept(this); if (!(currentPosition.getAttribute() instanceof MapAttribute<?, ?, ?>)) { invalid(expression, "Does not resolve to java.util.Map!"); } else { currentPosition.setCurrentType(currentPosition.getCurrentType()); } }