com.github.czyzby.websocket.serialization.impl.ReflectionArrayProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gdx-websocket-serialization Show documentation
Show all versions of gdx-websocket-serialization Show documentation
Custom cross-platform serialization without the use of reflection.
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