panda.bean.handler.ArrayBeanHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of panda-core Show documentation
Show all versions of panda-core Show documentation
Panda Core is the core module of Panda Framework, it contains commonly used utility classes similar to apache-commons.
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;
}
}