package cn.citycraft.GsonAgent.nms.bind;

import cn.citycraft.GsonAgent.nms.GsonHandle;
import net.minecraft.util.com.google.gson.Gson;
import net.minecraft.util.com.google.gson.TypeAdapter;
import net.minecraft.util.com.google.gson.TypeAdapterFactory;
import net.minecraft.util.com.google.gson.reflect.TypeToken;

@SuppressWarnings({ "unchecked", "rawtypes" })
public class TypeAdapterFactoryHandle implements cn.citycraft.GsonAgent.api.TypeAdapterFactory, net.minecraft.util.com.google.gson.TypeAdapterFactory {

	private final TypeAdapterFactory handle;

	protected TypeAdapterFactoryHandle(final TypeAdapterFactory handle) {
		this.handle = handle;
	}

	@Override
	public <T> TypeAdapterHandle<T> create(final cn.citycraft.GsonAgent.api.Gson paramGson, final cn.citycraft.GsonAgent.api.reflect.TypeToken<T> paramTypeToken) {
		return new TypeAdapterHandle(this.create(((GsonHandle) paramGson).getHandle(), (TypeToken<T>) paramTypeToken.getHandle()));
	}

	@Override
	public <T> TypeAdapter<T> create(final Gson paramGson, final TypeToken<T> paramTypeToken) {
		return this.getHandle().create(paramGson, paramTypeToken);
	}

	public TypeAdapterFactory getHandle() {
		return handle;
	}

}
