public static <S,T> List<T> shoehorn(Collection<S> feet, Class<T> shoe) { if (feet==null) { return null; } ArrayList<T> shoehornedFeet = new ArrayList<>(); for (S foot: feet) { shoehornedFeet.add(shoehorn(foot, shoe)); } return shoehornedFeet; }
public static <S,T> List<T> shoehorn(Collection<S> feet, Class<T> shoe) { if (feet==null) { return null; } ArrayList<T> shoehornedFeet = new ArrayList<>(); for (S foot: feet) { shoehornedFeet.add(shoehorn(foot, shoe)); } return shoehornedFeet; }
public <T> T getVariableValue(String variableId, Type type) { Object value = getVariableValue(variableId); if (value==null) { return (T) value; } if (type instanceof Class && ((Class)type).isAssignableFrom(value.getClass())) { return (T) value; } return ValueConverter.shoehorn(value, type); }
public <T> T getVariableValue(String variableId, Type type) { Object value = getVariableValue(variableId); if (value==null) { return (T) value; } if (type instanceof Class && ((Class)type).isAssignableFrom(value.getClass())) { return (T) value; } return ValueConverter.shoehorn(value, type); }
public static <S,T> T shoehorn(S foot, Type shoe) { if (shoe instanceof Class) { return shoehorn(foot, (Class<T>)shoe); } if (shoe instanceof GenericType) { GenericType genericType = (GenericType) shoe; if (genericType.getRawClass().isAssignableFrom(ArrayList.class) && foot instanceof Collection) { return (T) shoehorn((Collection)foot, (Class)genericType.getTypeArgs()[0]); } } throw new RuntimeException("don't know how to shoehorn "+foot+" into "+shoe); }
public static <S,T> T shoehorn(S foot, Type shoe) { if (shoe instanceof Class) { return shoehorn(foot, (Class<T>)shoe); } if (shoe instanceof GenericType) { GenericType genericType = (GenericType) shoe; if (genericType.getRawClass().isAssignableFrom(ArrayList.class) && foot instanceof Collection) { return (T) shoehorn((Collection)foot, (Class)genericType.getTypeArgs()[0]); } } throw new RuntimeException("don't know how to shoehorn "+foot+" into "+shoe); }