software.amazon.jsii.NativeType Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsii-runtime Show documentation
Show all versions of jsii-runtime Show documentation
Java client for jsii runtime
The newest version!
package software.amazon.jsii;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Internal
public abstract class NativeType {
protected static final JavaType[] NO_TYPE_PARAMS = {};
/**
* A {@link NativeType} representation for `void`.
*/
public static final NativeType VOID = NativeType.forClass(Void.class);
/**
* Creates a {@link NativeType} representation for classes that are neither {@link List} nor {@link Map} subclasses.
*
* @param simpleType the Java class to be represented.
* @param the static type of {@code simpleType}.
*
* @return a new {@link NativeType} instance.
*
* @throws IllegalArgumentException if a {@link List} or {@link Map} subclass is passed as an argument.
*/
public static NativeType forClass(final Class simpleType) {
return new SimpleNativeType<>(simpleType);
}
/**
* Creates a {@link NativeType} representation for a {@link List} of some {@code elementType}.
*
* @param elementType the type of elements in the {@link List}.
* @param the static type of the elements in the {@link List}.
*
* @return a new {@link NativeType} instance.
*/
public static NativeType> listOf(final NativeType elementType) {
return new ListNativeType<>(elementType);
}
/**
* Creates a {@link NativeType} representation for a {@link Map} of {@link String} to some {@code elementType}.
*
* @param elementType the type of values in the {@link Map}.
* @param the static type of the values in the {@link Map}.
*
* @return a new {@link NativeType} instance.
*/
public static NativeType