use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.DefaultName in project onos by opennetworkinglab.
the class TapiGlobalClassUtil method addNameList.
/**
* Add key-value to the ModelObject as "name-and-value" list.
*
* @param obj ModelObject
* @param kvs Key-value map
* @param <T> Type of ModelObject
*/
public static <T extends ModelObject> void addNameList(T obj, Map<String, String> kvs) {
@SuppressWarnings("unchecked") Class<T> cls = (Class<T>) obj.getClass();
try {
Method method = cls.getMethod("addToName", Name.class);
for (Entry<String, String> kv : kvs.entrySet()) {
DefaultName prop = new DefaultName();
prop.valueName(kv.getKey());
prop.value(kv.getValue());
method.invoke(obj, prop);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
log.error("Exception thrown", e);
}
}
use of org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.globalclass.DefaultName in project onos by opennetworkinglab.
the class TapiLocalClassUtil method addNameList.
/**
* Add key-value to the ModelObject as "name-and-value" list.
*
* @param obj ModelObject
* @param kvs Key-value map
* @param <T> Type of ModelObject
*/
public static <T extends ModelObject> void addNameList(T obj, Map<String, String> kvs) {
@SuppressWarnings("unchecked") Class<T> cls = (Class<T>) obj.getClass();
try {
Method method = cls.getMethod("addToName", Name.class);
for (Entry<String, String> kv : kvs.entrySet()) {
DefaultName prop = new DefaultName();
prop.valueName(kv.getKey());
prop.value(kv.getValue());
method.invoke(obj, prop);
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
log.error("Exception thrown", e);
}
}
Aggregations