private ImplicitCollectionMapperForClass getOrCreateMapper(Class definedIn) { ImplicitCollectionMapperForClass mapper = (ImplicitCollectionMapperForClass)classNameToMapper .get(definedIn); if (mapper == null) { mapper = new ImplicitCollectionMapperForClass(definedIn); classNameToMapper.put(definedIn, mapper); } return mapper; }
mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName, keyFieldName));
} else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getFieldNameForItemTypeAndName(itemType, itemFieldName) : null;
mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName, keyFieldName));
mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName, keyFieldName));
mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName, keyFieldName));
mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName, keyFieldName));
mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName, keyFieldName));
mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName, keyFieldName));
} else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getFieldNameForItemTypeAndName(itemType, itemFieldName) : null;
} else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getFieldNameForItemTypeAndName(itemType, itemFieldName) : null;
} else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass()); return mapper != null ? mapper.getFieldNameForItemTypeAndName(itemType, itemFieldName) : null;
} else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getFieldNameForItemTypeAndName(itemType, itemFieldName) : null;
public void add(Class definedIn, String fieldName, String itemFieldName, Class itemType) { Field field = null; while (definedIn != Object.class) { try { field = definedIn.getDeclaredField(fieldName); break; } catch (SecurityException e) { throw new InitializationException( "Access denied for field with implicit collection", e); } catch (NoSuchFieldException e) { definedIn = definedIn.getSuperclass(); } } if (field == null) { throw new InitializationException("No field \"" + fieldName + "\" for implicit collection"); } else if (!Collection.class.isAssignableFrom(field.getType())) { throw new InitializationException("Field \"" + fieldName + "\" declares no collection"); } ImplicitCollectionMapperForClass mapper = getOrCreateMapper(definedIn); mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName)); }
public String getFieldNameForItemTypeAndName(final Class<?> itemType, final String itemFieldName) { ImplicitCollectionMappingImpl unnamed = null; for (final NamedItemType itemTypeForFieldName : namedItemTypeToDef.keySet()) { final ImplicitCollectionMappingImpl def = namedItemTypeToDef.get(itemTypeForFieldName); if (itemType == Mapper.Null.class) { unnamed = def; break; } else if (itemTypeForFieldName.itemType.isAssignableFrom(itemType)) { if (def.getItemFieldName() != null) { if (def.getItemFieldName().equals(itemFieldName)) { return def.getFieldName(); } } else { if (unnamed == null || unnamed.getItemType() == null || def.getItemType() != null && unnamed.getItemType().isAssignableFrom(def.getItemType())) { unnamed = def; } } } } if (unnamed != null) { return unnamed.getFieldName(); } else { final ImplicitCollectionMapperForClass mapper = getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getFieldNameForItemTypeAndName(itemType, itemFieldName) : null; } }
public void add(Class definedIn, String fieldName, String itemFieldName, Class itemType) { Field field = null; while (definedIn != Object.class) { try { field = definedIn.getDeclaredField(fieldName); break; } catch (SecurityException e) { throw new InitializationException( "Access denied for field with implicit collection", e); } catch (NoSuchFieldException e) { definedIn = definedIn.getSuperclass(); } } if (field == null) { throw new InitializationException("No field \"" + fieldName + "\" for implicit collection"); } else if (!Collection.class.isAssignableFrom(field.getType())) { throw new InitializationException("Field \"" + fieldName + "\" declares no collection"); } ImplicitCollectionMapperForClass mapper = getOrCreateMapper(definedIn); mapper.add(new ImplicitCollectionMappingImpl(fieldName, itemType, itemFieldName)); }
private ImplicitCollectionMappingImpl getImplicitCollectionDefByItemFieldName( String itemFieldName) { if (itemFieldName == null) { return null; } else { ImplicitCollectionMappingImpl mapping = (ImplicitCollectionMappingImpl)itemFieldNameToDef.get(itemFieldName); if (mapping != null) { return mapping; } else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getImplicitCollectionDefByItemFieldName(itemFieldName) : null; } } }
private ImplicitCollectionMappingImpl getImplicitCollectionDefByItemFieldName( String itemFieldName) { if (itemFieldName == null) { return null; } else { ImplicitCollectionMappingImpl mapping = (ImplicitCollectionMappingImpl)itemFieldNameToDef.get(itemFieldName); if (mapping != null) { return mapping; } else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getImplicitCollectionDefByItemFieldName(itemFieldName) : null; } } }
private ImplicitCollectionMappingImpl getImplicitCollectionDefByItemFieldName( String itemFieldName) { if (itemFieldName == null) { return null; } else { ImplicitCollectionMappingImpl mapping = (ImplicitCollectionMappingImpl)itemFieldNameToDef.get(itemFieldName); if (mapping != null) { return mapping; } else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass(), null); return mapper != null ? mapper.getImplicitCollectionDefByItemFieldName(itemFieldName) : null; } } }
private ImplicitCollectionMappingImpl getImplicitCollectionDefByItemFieldName( String itemFieldName) { if (itemFieldName == null) { return null; } else { ImplicitCollectionMappingImpl mapping = (ImplicitCollectionMappingImpl)itemFieldNameToDef.get(itemFieldName); if (mapping != null) { return mapping; } else { ImplicitCollectionMapperForClass mapper = ImplicitCollectionMapper.this.getMapper(definedIn.getSuperclass()); return mapper != null ? mapper.getImplicitCollectionDefByItemFieldName(itemFieldName) : null; } } }