use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.
the class DefaultPropertyNameMatcherTest method testFullMatchCaseSensitive.
@Test
public void testFullMatchCaseSensitive() {
PropertyNameMatcher matcher = new DefaultPropertyNameMatcher("my_col", 0, false, true);
assertTrue(matcher.matches("myCol"));
assertFalse(matcher.matches("mycol"));
}
use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.
the class JoolTupleTest method testMetaDataOnJoolTuple.
@Test
public void testMetaDataOnJoolTuple() throws Exception {
// creates a new tuple allocated on the JVM heap
System.out.println("super " + Tuple3.class.toString());
for (Class<?> clazz : Tuple3.class.getInterfaces()) {
System.out.println("I " + clazz.toString());
}
ClassMeta<Tuple3<Long, Integer, Short>> cm = ReflectionService.newInstance().getClassMeta(new TypeReference<Tuple3<Long, Integer, Short>>() {
}.getType());
final PropertyFinder<Tuple3<Long, Integer, Short>> propertyFinder = cm.newPropertyFinder(isValidPropertyMeta);
final PropertyMeta<Tuple3<Long, Integer, Short>, Long> fieldA = propertyFinder.findProperty(new DefaultPropertyNameMatcher("elt0", 0, true, true), new Object[0]);
final PropertyMeta<Tuple3<Long, Integer, Short>, Integer> fieldB = propertyFinder.findProperty(new DefaultPropertyNameMatcher("elt1", 0, true, true), new Object[0]);
final PropertyMeta<Tuple3<Long, Integer, Short>, Short> fieldC = propertyFinder.findProperty(new DefaultPropertyNameMatcher("elt2", 0, true, true), new Object[0]);
final PropertyMeta<Tuple3<Long, Integer, Short>, ?> fieldD = propertyFinder.findProperty(new DefaultPropertyNameMatcher("elt3", 0, true, true), new Object[0]);
assertNotNull(fieldA);
assertNotNull(fieldB);
assertNotNull(fieldC);
assertNull(fieldD);
Tuple3<Long, Integer, Short> tuple = new Tuple3<Long, Integer, Short>(6l, 7, (short) 3);
assertTrue(fieldA instanceof ConstructorPropertyMeta);
assertTrue(fieldB instanceof ConstructorPropertyMeta);
assertTrue(fieldC instanceof ConstructorPropertyMeta);
Assert.assertEquals(6l, fieldA.getGetter().get(tuple).longValue());
Assert.assertEquals(7, fieldB.getGetter().get(tuple).intValue());
Assert.assertEquals(3, fieldC.getGetter().get(tuple).shortValue());
}
use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.
the class ConstantSourceMapperBuilderTest method testIssue495.
@Test
public void testIssue495() throws Exception {
TypeReference<Tuple2<TableA, List<Tuple3<TableB, List<TableC>, List<Tuple2<TableD, List<TableE>>>>>>> typeReference = new TypeReference<Tuple2<TableA, List<Tuple3<TableB, List<TableC>, List<Tuple2<TableD, List<TableE>>>>>>>() {
};
ClassMeta<Tuple2<TableA, List<Tuple3<TableB, List<TableC>, List<Tuple2<TableD, List<TableE>>>>>>> classMeta = this.classMeta.getReflectionService().getClassMeta(typeReference.getType());
Predicate<PropertyMeta<?, ?>> propertyFilter = new Predicate<PropertyMeta<?, ?>>() {
@Override
public boolean test(PropertyMeta<?, ?> propertyMeta) {
return true;
}
};
PropertyFinder<Tuple2<TableA, List<Tuple3<TableB, List<TableC>, List<Tuple2<TableD, List<TableE>>>>>>> propertyFinder = classMeta.newPropertyFinder(propertyFilter);
PropertyMeta<Tuple2<TableA, List<Tuple3<TableB, List<TableC>, List<Tuple2<TableD, List<TableE>>>>>>, Object> p1 = propertyFinder.findProperty(new DefaultPropertyNameMatcher("variableName", 0, false, false), new Object[0]);
PropertyMeta<Tuple2<TableA, List<Tuple3<TableB, List<TableC>, List<Tuple2<TableD, List<TableE>>>>>>, Object> p2 = propertyFinder.findProperty(new DefaultPropertyNameMatcher("variableName", 0, false, false), new Object[0]);
System.out.println("p1.getPath() = " + p1.getPath());
System.out.println("p2.getPath() = " + p2.getPath());
}
use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.
the class FastTupleTest method testMetaDataOnFastTuple.
@Test
public void testMetaDataOnFastTuple() throws Exception {
// creates a new tuple allocated on the JVM heap
@SuppressWarnings("unchecked") ClassMeta<FastTuple> cm = ReflectionService.newInstance().getClassMeta((Class<FastTuple>) tuple.getClass());
final PropertyFinder<FastTuple> propertyFinder = cm.newPropertyFinder(ConstantPredicate.<PropertyMeta<?, ?>>truePredicate());
final PropertyMeta<FastTuple, Long> fieldA = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldA", 0, true, true), new Object[0]);
final PropertyMeta<FastTuple, Integer> fieldB = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldB", 0, true, true), new Object[0]);
final PropertyMeta<FastTuple, Short> fieldC = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldC", 0, true, true), new Object[0]);
final PropertyMeta<FastTuple, ?> fieldD = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldD", 0, true, true), new Object[0]);
assertNotNull(fieldA);
assertNotNull(fieldB);
assertNotNull(fieldC);
assertNull(fieldD);
fieldA.getSetter().set(tuple, 6l);
assertEquals(6l, fieldA.getGetter().get(tuple).longValue());
fieldB.getSetter().set(tuple, 7);
assertEquals(7, fieldB.getGetter().get(tuple).intValue());
fieldC.getSetter().set(tuple, (short) 3);
assertEquals(3, fieldC.getGetter().get(tuple).shortValue());
}
use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.
the class FastTupleTest method testMetaDataOnFastTupleDirectMemory.
@Test
public void testMetaDataOnFastTupleDirectMemory() throws Exception {
final TupleSchema tupleSchema = TupleSchema.builder().addField("fieldA", Long.TYPE).addField("fieldB", Integer.TYPE).addField("fieldC", Short.TYPE).directMemory().build();
final FastTuple tuple = tupleSchema.createTuple();
// creates a new tuple allocated on the JVM heap
@SuppressWarnings("unchecked") ClassMeta<FastTuple> cm = ReflectionService.newInstance().getClassMeta((Class<FastTuple>) tuple.getClass());
final PropertyFinder<FastTuple> propertyFinder = cm.newPropertyFinder(ConstantPredicate.<PropertyMeta<?, ?>>truePredicate());
final PropertyMeta<FastTuple, Long> fieldA = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldA", 0, true, true), new Object[0]);
final PropertyMeta<FastTuple, Integer> fieldB = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldB", 0, true, true), new Object[0]);
final PropertyMeta<FastTuple, Short> fieldC = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldC", 0, true, true), new Object[0]);
final PropertyMeta<FastTuple, ?> fieldD = propertyFinder.findProperty(new DefaultPropertyNameMatcher("fieldD", 0, true, true), new Object[0]);
assertNotNull(fieldA);
assertNotNull(fieldB);
assertNotNull(fieldC);
assertNull(fieldD);
fieldA.getSetter().set(tuple, 6l);
assertEquals(6l, fieldA.getGetter().get(tuple).longValue());
fieldB.getSetter().set(tuple, 7);
assertEquals(7, fieldB.getGetter().get(tuple).intValue());
fieldC.getSetter().set(tuple, (short) 3);
assertEquals(3, fieldC.getGetter().get(tuple).shortValue());
}
Aggregations