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(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(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)); } }