private static <T extends AbstractModel> void constructVisitor(Class<T> cls, String tableName, TableMappingVisitors visitors, List<Property<?>> properties, Map<Property<?>, Property<?>> aliasMap) { if (cls != null) { TableModelMappingVisitor<T> visitor = new TableModelMappingVisitor<>(properties.toArray(new Property<?>[properties.size()]), aliasMap); visitors.put(cls, tableName, visitor); } }
public <T extends AbstractModel> T mapToModel(T dst, String tableAlias) { TableMappingVisitors visitors = getTableMappingVisitors(); if (visitors != null) { @SuppressWarnings("unchecked") TableModelMappingVisitor<T> mapper = visitors.get((Class<T>) dst.getClass(), tableAlias); if (mapper != null) { return mapper.map(this, dst); } } return dst; }
@Override public Void visitInteger(Property<Integer> property, T dst, ViewModel src) { Property<Integer> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
private static <T extends AbstractModel> void constructVisitor(Class<T> cls, String tableName, TableMappingVisitors visitors, List<Property<?>> properties, Map<Property<?>, Property<?>> aliasMap) { if (cls != null) { TableModelMappingVisitor<T> visitor = new TableModelMappingVisitor<>(properties.toArray(new Property<?>[properties.size()]), aliasMap); visitors.put(cls, tableName, visitor); } }
@Override public Void visitBlob(Property<byte[]> property, T dst, ViewModel src) { Property<byte[]> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitDouble(Property<Double> property, T dst, ViewModel src) { Property<Double> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
public <T extends AbstractModel> T mapToModel(T dst, String tableAlias) { TableMappingVisitors visitors = getTableMappingVisitors(); if (visitors != null) { @SuppressWarnings("unchecked") TableModelMappingVisitor<T> mapper = visitors.get((Class<T>) dst.getClass(), tableAlias); if (mapper != null) { return mapper.map(this, dst); } } return dst; }
@Override public Void visitString(Property<String> property, T dst, ViewModel src) { Property<String> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitBoolean(Property<Boolean> property, T dst, ViewModel src) { Property<Boolean> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitLong(Property<Long> property, T dst, ViewModel src) { Property<Long> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitBoolean(Property<Boolean> property, T dst, ViewModel src) { Property<Boolean> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitDouble(Property<Double> property, T dst, ViewModel src) { Property<Double> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitLong(Property<Long> property, T dst, ViewModel src) { Property<Long> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitInteger(Property<Integer> property, T dst, ViewModel src) { Property<Integer> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitBlob(Property<byte[]> property, T dst, ViewModel src) { Property<byte[]> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }
@Override public Void visitString(Property<String> property, T dst, ViewModel src) { Property<String> toSet = getPropertyToSet(property); if (src.containsValue(property)) { dst.set(toSet, src.get(property)); } return null; }