public static void validateMappingRequest(Object srcObj) { if (srcObj == null) { MappingUtils.throwMappingException("Source object must not be null"); } }
public void validate() { if (srcField == null) { MappingUtils.throwMappingException("src field must be specified"); } if (destField == null) { MappingUtils.throwMappingException("dest field must be specified"); } }
public static void validateMappingRequest(Object srcObj) { if (srcObj == null) { MappingUtils.throwMappingException("Source object must not be null"); } }
public static <T> T newInstance(Class<T> clazz) { T result = null; try { result = clazz.newInstance(); } catch (InstantiationException e) { MappingUtils.throwMappingException(e); } catch (IllegalAccessException e) { MappingUtils.throwMappingException(e); } return result; }
@Override public Object clone() { Object result = null; try { result = super.clone(); } catch (CloneNotSupportedException e) { MappingUtils.throwMappingException(e); } return result; }
public Class<?> loadClass(String className) { Class<?> result = null; try { result = ClassUtils.getClass(classLoader, className); } catch (ClassNotFoundException e) { MappingUtils.throwMappingException(e); } return result; }
public MappingFileData read(InputStream xmlStream) { MappingFileData result = null; try { Document document = documentBuilder.parse(xmlStream); result = parser.read(document); } catch (Throwable e) { log.error("Error while loading dozer mapping InputStream: [" + xmlStream + "]", e); MappingUtils.throwMappingException(e); } return result; }
private PropertyDescriptor getPropertyDescriptor(HintContainer deepIndexHintContainer) { if (pd == null) { pd = ReflectionUtils.findPropertyDescriptor(clazz, fieldName, deepIndexHintContainer); if (pd == null) { MappingUtils.throwMappingException("Property: '" + fieldName + "' not found in Class: " + clazz); } } return pd; }
private Method findMethod(Class<?> actualClass, String createMethod) { Method method = null; try { method = ReflectionUtils.getMethod(actualClass, createMethod, null); } catch (NoSuchMethodException e) { MappingUtils.throwMappingException(e); } return method; }
public static Method getMethod(Class<?> clazz, String methodName) { Method result = findMethod(clazz, methodName); if (result == null) { MappingUtils.throwMappingException("No method found for class:" + clazz + " and method name:" + methodName); } return result; }
private <T> Class<? extends T> loadBeanType(String classLoaderName, DozerClassLoader classLoader, Class<T> iface) { Class<?> beanType = classLoader.loadClass(classLoaderName); if (beanType != null && !iface.isAssignableFrom(beanType)) { MappingUtils.throwMappingException("Incompatible types: " + iface.getName() + " and " + classLoaderName); } return (Class<? extends T>) beanType; }
public static void validateMappingRequest(Object srcObj, Object destObj) { validateMappingRequest(srcObj); if (destObj == null) { MappingUtils.throwMappingException("Destination object must not be null"); } }
public Class<?> getWriteMethodPropertyType() { try { return getWriteMethod().getParameterTypes()[0]; } catch (Exception e) { MappingUtils.throwMappingException(e); return null; } }
private PropertyDescriptor getPropertyDescriptor(HintContainer deepIndexHintContainer) { if (pd == null) { pd = ReflectionUtils.findPropertyDescriptor(clazz, fieldName, deepIndexHintContainer); if (pd == null) { MappingUtils.throwMappingException("Property: " + fieldName + " not found in Class: " + clazz); } } return pd; }
public ConfigurationBuilder allowedException(Class type) { if (!RuntimeException.class.isAssignableFrom(type)) { MappingUtils.throwMappingException("allowed-exception Type must extend java.lang.RuntimeException: " + type.getName()); } configuration.getAllowedExceptions().getExceptions().add(type); return this; }
public ConfigurationBuilder allowedException(Class type) { if (!RuntimeException.class.isAssignableFrom(type)) { MappingUtils.throwMappingException( "allowed-exception Type must extend java.lang.RuntimeException: " + type.getName()); } configuration.getAllowedExceptions().getExceptions().add(type); return this; }
public static Object prepareIndexedCollection(Class<?> collectionType, Object existingCollection, Object collectionEntry, int index) { Object result = null; if (collectionType.isArray()) { result = prepareIndexedArray(collectionType, existingCollection, collectionEntry, index); } else if (Collection.class.isAssignableFrom(collectionType)) { result = prepareIndexedCollectionType(collectionType, existingCollection, collectionEntry, index); } else { throwMappingException("Only types java.lang.Object[] and java.util.Collection are supported for indexed properties."); } return result; }
public void addCache(Cache cache) { synchronized (cachesMap) { String name = cache.getName(); if (cacheExists(name)) { MappingUtils.throwMappingException("Cache already exists with name: " + name); } cachesMap.put(name, cache); } }
protected Object invokeReadMethod(Object target) { Object result = null; try { result = ReflectionUtils.invoke(getReadMethod(), target, null); } catch (NoSuchMethodException e) { MappingUtils.throwMappingException(e); } return result; }
@Override protected void invokeWriteMethod(Object target, Object value) { if (key == null) { throw new MappingException("key must be specified"); } try { ReflectionUtils.invoke(getWriteMethod(), target, new Object[]{key, value}); } catch (NoSuchMethodException e) { MappingUtils.throwMappingException(e); } }