org.javers.core.metamodel.type.ArrayType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-core Show documentation
Show all versions of javers-core Show documentation
JaVers - object auditing and diff framework for Java
package org.javers.core.metamodel.type;
import org.javers.common.collections.EnumerableFunction;
import org.javers.common.collections.Lists;
import org.javers.common.validation.Validate;
import org.javers.core.metamodel.object.EnumerationAwareOwnerContext;
import org.javers.core.metamodel.object.OwnerContext;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
/**
* @author bartosz walacik
*/
public class ArrayType extends ContainerType {
public ArrayType(Type baseJavaType) {
super(baseJavaType);
}
@Override
public List getConcreteClassTypeArguments() {
return (List)Lists.immutableListOf( getBaseJavaClass().getComponentType() );
}
@Override
public Object map(Object sourceArray, EnumerableFunction mapFunction, OwnerContext owner) {
Validate.argumentsAreNotNull(sourceArray, mapFunction, owner);
int len = Array.getLength(sourceArray);
Object targetArray = newPrimitiveOrObjectArray(len);
EnumerationAwareOwnerContext enumerationContext = new IndexableEnumerationOwnerContext(owner);
for (int i=0; i