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; }
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.getRealCurrentType()); } return possibleTargets; }
public List<TargetType> getPossibleTargetTypes() { List<PathPosition> positions = pathPositions; int size = positions.size(); if (managedType != null && size == 1 && positions.get(0).getAttribute() == null && managedType.getJavaType().equals(positions.get(0).getRealCurrentClass())) { // When we didn't resolve any property, the expression is probably static and we can't give types in that case return Collections.emptyList(); } List<TargetType> possibleTargets = new ArrayList<>(size); for (int i = 0; i < size; i++) { PathPosition position = positions.get(i); possibleTargets.add(new TargetTypeImpl(position.hasCollectionJoin(), position.getAttribute(), position.getRealCurrentClass(), position.getKeyCurrentClass(), position.getCurrentClass())); } return possibleTargets; }
@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(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()); } }
@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)); } }
@Override public void visit(MapEntryExpression expression) { expression.getPath().accept(this); currentPosition.setAttribute(new MapEntryAttribute<>((MapAttribute<?, Object, ?>) currentPosition.getAttribute())); currentPosition.setCurrentType(metamodel.type(Map.Entry.class)); }
@Override public void visit(MapEntryExpression expression) { expression.getPath().accept(this); if (!(currentPosition.getAttribute() instanceof MapAttribute<?, ?, ?>)) { invalid(expression, "Does not resolve to java.util.Map!"); } else { currentPosition.setAttribute(null); currentPosition.setCurrentType(metamodel.type(Map.Entry.class)); } }
@Override public void visit(ListIndexExpression expression) { expression.getPath().accept(this); if (!(currentPosition.getAttribute() instanceof ListAttribute<?, ?>)) { invalid(expression, "Does not resolve to java.util.List!"); } else { currentPosition.setAttribute(new ListIndexAttribute<>((ListAttribute<?, ?>) currentPosition.getAttribute())); currentPosition.setCurrentType(metamodel.type(Integer.class)); } }
@Override public void visit(MapEntryExpression expression) { expression.getPath().accept(this); currentPosition.setAttribute(new MapEntryAttribute<>((MapAttribute<?, Object, ?>) currentPosition.getAttribute())); currentPosition.setCurrentType(metamodel.type(Map.Entry.class)); }
@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)); } }
@Override public void visit(MapKeyExpression expression) { expression.getPath().accept(this); if (!(currentPosition.getAttribute() instanceof MapAttribute<?, ?, ?>)) { invalid(expression, "Does not resolve to java.util.Map!"); } else { currentPosition.setAttribute(new MapKeyAttribute<>((MapAttribute<?, Object, ?>) currentPosition.getAttribute())); currentPosition.setCurrentType(((MapAttribute<?, Object, ?>) currentPosition.getAttribute()).getKeyType()); } }