private static <T> List<T> createEntityFromTuple(List<Tuple> tuples, Class<T> entity) { List<T> entities = new ArrayList<>(); for (Tuple t : tuples) { T el; try { el = entity.getConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new AssertionError(); } for (TupleElement<?> te : t.getElements()) { Object o = t.get(te); try { Field f = getFieldFromEntity(entity, te.getAlias()); f.setAccessible(true); f.set(el, o); } catch (NoSuchFieldException | IllegalAccessException e1) { throw new NoSuchEntityFieldException(e1.getMessage(), te.getAlias(), entity.getSimpleName()); } } entities.add(el); } return entities; }
@Override public <X> X get(TupleElement<X> element) { throw new UnsupportedOperationException(); }
@Override public List<TupleElement<?>> getElements() { throw new UnsupportedOperationException(); }
@Override public <X> X get(TupleElement<X> tupleElement) { throw new UnsupportedOperationException("not implemented"); }
@Override public List<TupleElement<?>> getElements() { throw new UnsupportedOperationException("not implemented"); }
@Test(expected = UnsupportedOperationException.class) public void testGetByTupleNotSupported() { impl.get((TupleElement<?>) null); }
public List<TupleElement<?>> getElements() { return tuple.getElements(); }
public <X> X get(TupleElement<X> tupleElement) { return getSecureResult(tuple.get(tupleElement)); }
static final String elemTypeName(TupleElement<?> e) { return e.getJavaType().getName(); }