| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.dozer.classmap.generator; |
| 17 | |
|
| 18 | |
import org.dozer.classmap.ClassMap; |
| 19 | |
import org.dozer.classmap.Configuration; |
| 20 | |
import org.dozer.fieldmap.DozerField; |
| 21 | |
import org.dozer.fieldmap.FieldMap; |
| 22 | |
import org.dozer.fieldmap.GenericFieldMap; |
| 23 | |
import org.dozer.util.MappingUtils; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
public final class GeneratorUtils { |
| 29 | |
private static final String CLASS = "class"; |
| 30 | |
private static final String CALLBACK = "callback"; |
| 31 | |
private static final String CALLBACKS = "callbacks"; |
| 32 | |
|
| 33 | 0 | private GeneratorUtils() {} |
| 34 | |
|
| 35 | |
public static boolean shouldIgnoreField(String fieldName, Class<?> srcType, Class<?> destType) { |
| 36 | 28153 | if (CLASS.equals(fieldName)) { |
| 37 | 1024 | return true; |
| 38 | |
} |
| 39 | 27129 | if ((CALLBACK.equals(fieldName) || CALLBACKS.equals(fieldName)) |
| 40 | |
&& (MappingUtils.isProxy(srcType) || MappingUtils.isProxy(destType))) { |
| 41 | 14 | return true; |
| 42 | |
} |
| 43 | 27115 | return false; |
| 44 | |
} |
| 45 | |
|
| 46 | |
public static void addGenericMapping(ClassMap classMap, Configuration configuration, String srcName, String destName) { |
| 47 | 13427 | FieldMap fieldMap = new GenericFieldMap(classMap); |
| 48 | |
|
| 49 | 13427 | fieldMap.setSrcField(new DozerField(srcName, null)); |
| 50 | 13427 | fieldMap.setDestField(new DozerField(destName, null)); |
| 51 | |
|
| 52 | |
|
| 53 | 13427 | MappingUtils.applyGlobalCopyByReference(configuration, fieldMap, classMap); |
| 54 | 13427 | classMap.addFieldMapping(fieldMap); |
| 55 | 13427 | } |
| 56 | |
} |