All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jvnet.hyperjaxb3.item.ItemUtils Maven / Gradle / Ivy

There is a newer version: 0.6.2
Show newest version
package org.jvnet.hyperjaxb3.item;

import java.util.List;

public class ItemUtils {

	public static > ItemType create(
			Class 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 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