@Test public void with_nested_factoryExpression() { Map<String,Expression<?>> bindings = new LinkedHashMap<String,Expression<?>>(); bindings.put("age", age); bindings.put("name", new Concatenation(name, name2)); QBean<Entity> beanProjection = new QBean<Entity>(Entity.class, true, bindings); FactoryExpression<Entity> wrappedProjection = FactoryExpressionUtils.wrap(beanProjection); Entity bean = wrappedProjection.newInstance(30, "Fri","tz"); assertEquals("Fritz", bean.name); } }
@Test public void with_nested_factoryExpression() { Map<String,Expression<?>> bindings = new LinkedHashMap<String,Expression<?>>(); bindings.put("age", age); bindings.put("name", new Concatenation(name, name2)); QBean<Entity> beanProjection = new QBean<Entity>(Entity.class, bindings); FactoryExpression<Entity> wrappedProjection = FactoryExpressionUtils.wrap(beanProjection); Entity bean = wrappedProjection.newInstance(30, "Fri","tz"); assertEquals("Fritz", bean.getName()); }
@Test public void with_nested_factoryExpression2() { QBean<Entity> beanProjection = new QBean<Entity>(Entity.class, age, ExpressionUtils.as(new Concatenation(name, name2), "name")); FactoryExpression<Entity> wrappedProjection = FactoryExpressionUtils.wrap(beanProjection); Entity bean = wrappedProjection.newInstance(30, "Fri","tz"); assertEquals("Fritz", bean.getName()); }
MyArray< String > array = new MyArray<>(); ... // add items Concatenation concatenation = new Concatenation(); array.forEach( concatenation ); String concat = concatenation.concat;
@Test public void nested_tuple_projection() { Concatenation concat = new Concatenation(employee.firstname, employee.lastname); List<Tuple> tuples = query().from(employee) .select(employee.firstname, employee.lastname, concat).fetch(); assertFalse(tuples.isEmpty()); for (Tuple tuple : tuples) { String firstName = tuple.get(employee.firstname); String lastName = tuple.get(employee.lastname); assertEquals(firstName + lastName, tuple.get(concat)); } }
@Test public void nestedProjection() { Concatenation concat = new Concatenation(cat.name, cat.name); List<Tuple> tuples = query().from(cat).select(cat.name, concat).fetch(); assertFalse(tuples.isEmpty()); for (Tuple tuple : tuples) { assertEquals( tuple.get(concat), tuple.get(cat.name) + tuple.get(cat.name)); } }