package org.opendaylight.neutron.transcriber;
+import java.lang.reflect.Method;
+
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
return result;
}
+ // this method uses reflection to update an object from it's delta.
+
+ protected boolean overwrite(Object target, Object delta) {
+ Method[] methods = target.getClass().getMethods();
+
+ for(Method toMethod: methods){
+ if(toMethod.getDeclaringClass().equals(target.getClass())
+ && toMethod.getName().startsWith("set")){
+
+ String toName = toMethod.getName();
+ String fromName = toName.replace("set", "get");
+
+ try {
+ Method fromMethod = delta.getClass().getMethod(fromName);
+ Object value = fromMethod.invoke(delta, (Object[])null);
+ if(value != null){
+ toMethod.invoke(target, value);
+ }
+ } catch (Exception e) {
+ LOGGER.error("Error in overwrite", e);
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
@Override
public void close() throws Exception {
// TODO Auto-generated method stub