Search in sources :

Example 11 with DefaultPropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.

the class ConstructorPropertyMetaTest method testSetterIsNullSetter.

@Test
public void testSetterIsNullSetter() throws Exception {
    PropertyMeta<CObject, Object> property = classMeta.newPropertyFinder(isValidPropertyMeta).findProperty(new DefaultPropertyNameMatcher("p1", 0, false, false), new Object[0]);
    assertTrue(property.getSetter() instanceof NullSetter);
}
Also used : DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) NullSetter(org.simpleflatmapper.reflect.setter.NullSetter) Test(org.junit.Test)

Example 12 with DefaultPropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.

the class DefaultPropertyNameMatcherTest method testFullMatchExactMath.

@Test
public void testFullMatchExactMath() {
    PropertyNameMatcher matcher = new DefaultPropertyNameMatcher("my_col", 0, true, false);
    assertTrue(matcher.matches("my_col"));
    assertTrue(matcher.matches("my_COL"));
    assertFalse(matcher.matches("myCol"));
}
Also used : DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) PropertyNameMatcher(org.simpleflatmapper.reflect.meta.PropertyNameMatcher) DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) Test(org.junit.Test)

Example 13 with DefaultPropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.

the class DefaultPropertyNameMatcherTest method testMatchIndex.

@Test
public void testMatchIndex() {
    assertEquals(2, new DefaultPropertyNameMatcher("elt2", 0, false, false).matchIndex().getIndexValue());
    assertEquals(2, new DefaultPropertyNameMatcher("elt_2", 0, false, false).matchIndex().getIndexValue());
    assertNull(new DefaultPropertyNameMatcher("elt_ipv2", 0, false, false).matchIndex());
}
Also used : DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) Test(org.junit.Test)

Example 14 with DefaultPropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.

the class DefaultPropertyNameMatcherTest method testFullMatch.

@Test
public void testFullMatch() {
    PropertyNameMatcher matcher = new DefaultPropertyNameMatcher("my_Col", 0, false, false);
    assertTrue(matcher.matches("myCol"));
    assertTrue(matcher.matches("my_Col"));
    assertTrue(matcher.matches("my Col"));
    assertFalse(matcher.matches("myCo"));
    assertFalse(matcher.matches("my__Col"));
    assertFalse(matcher.matches("myCol2"));
}
Also used : DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) PropertyNameMatcher(org.simpleflatmapper.reflect.meta.PropertyNameMatcher) DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) Test(org.junit.Test)

Example 15 with DefaultPropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher in project SimpleFlatMapper by arnaudroger.

the class SelfPropertyMetaTest method testDirect.

@Test
public void testDirect() {
    ClassMeta<String> direct = ReflectionService.newInstance().getClassMeta(String.class);
    PropertyMeta<String, Object> property = direct.newPropertyFinder(isValidPropertyMeta).findProperty(new DefaultPropertyNameMatcher("bbb", 0, true, true), new Object[0]);
    assertTrue("Expect SelfPropertyMeta " + property, property instanceof SelfPropertyMeta);
    assertEquals("SelfPropertyMeta{type=class java.lang.String,name=self}", property.toString());
    assertTrue(property.getGetter() instanceof IdentityGetter);
    assertTrue(NullSetter.isNull(property.getSetter()));
    assertEquals("{this}", property.getPath());
    assertEquals(String.class, direct.getType());
}
Also used : IdentityGetter(org.simpleflatmapper.reflect.getter.IdentityGetter) SelfPropertyMeta(org.simpleflatmapper.reflect.meta.SelfPropertyMeta) DefaultPropertyNameMatcher(org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 DefaultPropertyNameMatcher (org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher)16 PropertyMeta (org.simpleflatmapper.reflect.meta.PropertyMeta)4 PropertyNameMatcher (org.simpleflatmapper.reflect.meta.PropertyNameMatcher)4 Predicate (org.simpleflatmapper.util.Predicate)3 TypeReference (org.simpleflatmapper.util.TypeReference)3 FastTuple (com.boundary.tuple.FastTuple)2 List (java.util.List)2 DbObject (org.simpleflatmapper.test.beans.DbObject)2 Tuple3 (org.simpleflatmapper.tuple.Tuple3)2 TupleSchema (com.boundary.tuple.TupleSchema)1 ResultSet (java.sql.ResultSet)1 Tuple3 (org.jooq.lambda.tuple.Tuple3)1 JdbcColumnKey (org.simpleflatmapper.jdbc.JdbcColumnKey)1 LongFieldMapper (org.simpleflatmapper.map.fieldmapper.LongFieldMapper)1 PropertyMapping (org.simpleflatmapper.map.mapper.PropertyMapping)1 FieldMapperColumnDefinition (org.simpleflatmapper.map.property.FieldMapperColumnDefinition)1 IdentityGetter (org.simpleflatmapper.reflect.getter.IdentityGetter)1 ConstructorPropertyMeta (org.simpleflatmapper.reflect.meta.ConstructorPropertyMeta)1 SelfPropertyMeta (org.simpleflatmapper.reflect.meta.SelfPropertyMeta)1