/** * Lookups {@link DbEntityDescriptor} for some type and registers the type if is new. * <p> * Returns <code>null</code> for core classes from <code>java</code> run-time packages! * Some types are <b>not</b> entities, i.e. domain objects. Instead, primitive entities * are simply mapped to one column. */ public <E> DbEntityDescriptor<E> lookupType(final Class<E> type) { String typeName = type.getName(); if (StringUtil.startsWithOne(typeName, primitiveEntitiesPrefixes) != -1) { return null; } DbEntityDescriptor<E> ded = descriptorsMap.get(type); if (ded == null) { ded = registerType(type); } return ded; }
@Test void testStartWith() { assertTrue(StringUtil.startsWithChar("asd", 'a')); assertFalse(StringUtil.startsWithChar("asd", 's')); assertFalse(StringUtil.startsWithChar("", 'a')); assertTrue(StringUtil.endsWithChar("asd", 'd')); assertFalse(StringUtil.endsWithChar("asd", 's')); assertFalse(StringUtil.endsWithChar("", 'd')); assertEquals(3, StringUtil.startsWithOne("qwe123", "Qwe", null, ".", "qwe")); assertEquals(-1, StringUtil.startsWithOne("qwe123", "Qwe", null, ".", "we")); assertEquals(0, StringUtil.startsWithOneIgnoreCase("qwe123", "Qwe", null, ".", "qwe")); assertEquals(-1, StringUtil.startsWithOneIgnoreCase("qwe123", "we", null, ".", "we")); assertEquals(3, StringUtil.endsWithOne("qwezxc", "Zxc", null, ".", "zxc")); assertEquals(-1, StringUtil.endsWithOne("qwezxc", "Zxc", null, ".", "zx")); assertEquals(0, StringUtil.endsWithOneIgnoreCase("qweZXC", "Zxc", null, ".", "zxc")); assertEquals(-1, StringUtil.endsWithOneIgnoreCase("qweZXC", "zx", null, ".", "zx")); }
/** * Lookups {@link DbEntityDescriptor} for some type and registers the type if is new. * <p> * Returns <code>null</code> for core classes from <code>java</code> run-time packages! * Some types are <b>not</b> entities, i.e. domain objects. Instead, primitive entities * are simply mapped to one column. */ public DbEntityDescriptor lookupType(Class type) { String typeName = type.getName(); if (StringUtil.startsWithOne(typeName, primitiveEntitiesPrefixes) != -1) { return null; } DbEntityDescriptor ded = descriptorsMap.get(type); if (ded == null) { ded = registerType(type); } return ded; }
/** * Lookups {@link DbEntityDescriptor} for some type and registers the type if is new. * <p> * Returns <code>null</code> for core classes from <code>java</code> run-time packages! * Some types are <b>not</b> entities, i.e. domain objects. Instead, primitive entities * are simply mapped to one column. */ public <E> DbEntityDescriptor<E> lookupType(final Class<E> type) { String typeName = type.getName(); if (StringUtil.startsWithOne(typeName, primitiveEntitiesPrefixes) != -1) { return null; } DbEntityDescriptor<E> ded = descriptorsMap.get(type); if (ded == null) { ded = registerType(type); } return ded; }