Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.nedap.archie.creation;
import com.google.common.collect.Lists;
import com.nedap.archie.aom.CObject;
import com.nedap.archie.rminfo.ModelInfoLookup;
import com.nedap.archie.rminfo.RMAttributeInfo;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Type;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* Utility to create Reference model objects based on their RM name. Also can set attribute values on RM Objects based
* on their RM Attribute name.
*
* Created by pieter.bos on 03/02/16.
*/
public class RMObjectCreator {
private final ModelInfoLookup modelInfoLookup;
public RMObjectCreator(ModelInfoLookup lookup) {
this.modelInfoLookup = lookup;
}
public T create(CObject constraint) {
Class> clazz = modelInfoLookup.getClassToBeCreated(constraint.getRmTypeName());
if(clazz == null) {
throw new IllegalArgumentException("cannot construct RMObject because of unknown constraint name " + constraint.getRmTypeName() + " full constraint " + constraint);
}
try {
Object result = clazz.newInstance();
modelInfoLookup.processCreatedObject(result, constraint);
return (T) result;
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException("error creating class " + constraint.getRmTypeName(), e);
}
}
public void set(Object object, String rmAttributeName, List