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

com.github.czyzby.websocket.serialization.impl.ReflectionArrayProvider Maven / Gradle / Ivy

The newest version!
package com.github.czyzby.websocket.serialization.impl;

import com.badlogic.gdx.utils.reflect.ArrayReflection;
import com.github.czyzby.websocket.serialization.ArrayProvider;

/** Uses reflection to construct typed arrays.
 *
 * @author MJ
 *
 * @param  type of values stored in the array. */
public class ReflectionArrayProvider implements ArrayProvider {
    private final Class arrayType;

    /** @param arrayType type of arrays produced by the provider. */
    public ReflectionArrayProvider(final Class arrayType) {
        this.arrayType = arrayType;
    }

    @Override
    @SuppressWarnings("unchecked")
    public Type[] getArray(final int size) {
        return (Type[]) ArrayReflection.newInstance(arrayType, size);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy