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

panda.bean.handler.ArrayBeanHandler Maven / Gradle / Ivy

Go to download

Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.

There is a newer version: 1.8.0
Show newest version
package panda.bean.handler;

import java.lang.reflect.Array;
import java.lang.reflect.Type;

import panda.bean.Beans;
import panda.lang.reflect.Types;

/**
 * 
 * @param  class type
 */
public class ArrayBeanHandler extends AbstractArrayBeanHandler {
	/**
	 * Constructor
	 * @param beans bean handler factory
	 * @param type bean type
	 */
	public ArrayBeanHandler(Beans beans, Type type) {
		super(beans, type);

		if (!Types.isArrayType(type)) {
			throw new IllegalArgumentException(type + " is not a array type");
		}
	}

	@Override
	protected int getSize(T array) {
		return Array.getLength(array);
	}
	
	@Override
	protected Object getElement(T array, int index) {
		return Array.get(array, index);
	}
	
	@Override
	protected boolean setElement(T array, int index, Object value) {
		Array.set(array, index, value);
		return true;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy