Search in sources :

Example 1 with PropertyNameMatcher

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

the class PropertyMappingsBuilder method _addProperty.

@SuppressWarnings("unchecked")
private <P> PropertyMapping<T, P, K, D> _addProperty(final K key, final D columnDefinition, Consumer<? super K> propertyNotFound) {
    if (!modifiable)
        throw new IllegalStateException("Builder not modifiable");
    if (columnDefinition.ignore()) {
        propertyMappingsBuilderProbe.ignore(key, columnDefinition);
        properties.add(null);
        return null;
    }
    PropertyFinder<T> effectivePropertyFinder = wrapPropertyFinder(this.propertyFinder);
    PropertyNameMatcher propertyNameMatcher = propertyNameMatcherFactory.newInstance(key);
    final PropertyMeta<T, P> prop = (PropertyMeta<T, P>) effectivePropertyFinder.findProperty(propertyNameMatcher, columnDefinition.properties(), propertyMappingsBuilderProbe.propertyFinderProbe(propertyNameMatcher));
    if (prop == null) {
        propertyNotFound.accept(key);
        properties.add(null);
        return null;
    } else {
        PropertyMapping<T, P, K, D> propertyMapping = addProperty(key, columnDefinition, prop);
        propertyMappingsBuilderProbe.map(key, columnDefinition, prop);
        handleSelfPropertyMetaInvalidation(propertyNotFound);
        return propertyMapping;
    }
}
Also used : PropertyNameMatcher(org.simpleflatmapper.reflect.meta.PropertyNameMatcher) SelfPropertyMeta(org.simpleflatmapper.reflect.meta.SelfPropertyMeta) PropertyMeta(org.simpleflatmapper.reflect.meta.PropertyMeta)

Example 2 with PropertyNameMatcher

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

the class DefaultPropertyNameMatcherTest method testStartOf.

@Test
public void testStartOf() {
    PropertyNameMatcher matcher = new DefaultPropertyNameMatcher("my_Col_top_bottom", 0, false, false);
    assertTrue(matcher.partialMatch("myCol").getLeftOverMatcher().partialMatch("top").getLeftOverMatcher().matches("bottom"));
    assertTrue(matcher.partialMatch("my_Col").getLeftOverMatcher().partialMatch("tOp").getLeftOverMatcher().matches("bottom"));
    assertTrue(matcher.partialMatch("my Col").getLeftOverMatcher().partialMatch("tOp").getLeftOverMatcher().matches("bottom"));
    assertNull(matcher.partialMatch("my__Col"));
    assertNull(matcher.partialMatch("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 3 with PropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.PropertyNameMatcher 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"));
}
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 4 with PropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.PropertyNameMatcher 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 5 with PropertyNameMatcher

use of org.simpleflatmapper.reflect.meta.PropertyNameMatcher 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)

Aggregations

PropertyNameMatcher (org.simpleflatmapper.reflect.meta.PropertyNameMatcher)5 Test (org.junit.Test)4 DefaultPropertyNameMatcher (org.simpleflatmapper.reflect.meta.DefaultPropertyNameMatcher)4 PropertyMeta (org.simpleflatmapper.reflect.meta.PropertyMeta)1 SelfPropertyMeta (org.simpleflatmapper.reflect.meta.SelfPropertyMeta)1