org.jvnet.hyperjaxb3.item.ItemUtils Maven / Gradle / Ivy
package org.jvnet.hyperjaxb3.item;
import java.util.List;
public class ItemUtils {
public static > ItemType create(
Class extends ItemType> itemClass, T value) {
try {
final ItemType item = itemClass.newInstance();
item.setItem(value);
return item;
} catch (InstantiationException ex) {
throw new IllegalArgumentException("Error in default constructor.",
ex);
} catch (IllegalAccessException ex) {
throw new IllegalArgumentException("Error in default constructor.",
ex);
}
}
public static boolean shouldBeWrapped(List core) {
if (core == null || !(core instanceof ItemList)) {
return true;
} else {
return false;
}
}
public static > List wrap(List core,
List items, Class extends ItemType> itemClass) {
if (core == null || !(core instanceof ItemList)) {
final List newCore = new DefaultItemList(items,
itemClass);
if (core != null) {
newCore.addAll(core);
}
return newCore;
} else {
return core;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy