Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.fasterxml.jackson.databind.type;
import java.lang.reflect.Array;
import com.fasterxml.jackson.databind.JavaType;
/**
* Array types represent Java arrays, both primitive and object valued.
* Further, Object-valued arrays can have element type of any other
* legal {@link JavaType}.
*/
public final class ArrayType
extends TypeBase
{
private static final long serialVersionUID = 1L;
/**
* Type of elements in the array.
*/
protected final JavaType _componentType;
/**
* We will also keep track of shareable instance of empty array,
* since it usually needs to be constructed any way; and because
* it is essentially immutable and thus can be shared.
*/
protected final Object _emptyArray;
protected ArrayType(JavaType componentType, TypeBindings bindings, Object emptyInstance,
Object valueHandler, Object typeHandler, boolean asStatic)
{
// No super-class, interfaces, for now
super(emptyInstance.getClass(), bindings, null, null,
componentType.hashCode(),
valueHandler, typeHandler, asStatic);
_componentType = componentType;
_emptyArray = emptyInstance;
}
public static ArrayType construct(JavaType componentType, TypeBindings bindings) {
return construct(componentType, bindings, null, null);
}
public static ArrayType construct(JavaType componentType, TypeBindings bindings,
Object valueHandler, Object typeHandler) {
// Figuring out raw class for generic array is actually bit tricky...
Object emptyInstance = Array.newInstance(componentType.getRawClass(), 0);
return new ArrayType(componentType, bindings, emptyInstance, valueHandler, typeHandler, false);
}
@Override
public JavaType withContentType(JavaType contentType) {
Object emptyInstance = Array.newInstance(contentType.getRawClass(), 0);
return new ArrayType(contentType, _bindings, emptyInstance,
_valueHandler, _typeHandler, _asStatic);
}
@Override
public ArrayType withTypeHandler(Object h)
{
if (h == _typeHandler) {
return this;
}
return new ArrayType(_componentType, _bindings, _emptyArray, _valueHandler, h, _asStatic);
}
@Override
public ArrayType withContentTypeHandler(Object h)
{
if (h == _componentType.