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

com.g2forge.alexandria.analysis.HBCEL Maven / Gradle / Ivy

package com.g2forge.alexandria.analysis;

import org.apache.bcel.generic.BasicType;
import org.apache.bcel.generic.ObjectType;
import org.apache.bcel.generic.Type;

import com.g2forge.alexandria.java.core.helpers.HArray;

public class HBCEL {
	public static java.lang.reflect.Type toJava(Type type) {
		if (type instanceof ObjectType) {
			try {
				return HBCEL.class.getClass().getClassLoader().loadClass(((ObjectType) type).getClassName());
			} catch (ClassNotFoundException e) {
				throw new RuntimeException(e);
			}
		}
		if (type instanceof BasicType) {
			if (type == BasicType.VOID) return Void.TYPE;
			if (type == BasicType.BOOLEAN) return Boolean.TYPE;
			if (type == BasicType.BYTE) return Byte.TYPE;
			if (type == BasicType.SHORT) return Short.TYPE;
			if (type == BasicType.INT) return Integer.TYPE;
			if (type == BasicType.LONG) return Long.TYPE;
			if (type == BasicType.FLOAT) return Float.TYPE;
			if (type == BasicType.DOUBLE) return Double.TYPE;
			if (type == BasicType.OBJECT) return Object.class;
		}
		throw new IllegalArgumentException();
	}

	public static java.lang.reflect.Type[] toJava(Type... types) {
		return HArray.map(java.lang.reflect.Type.class, HBCEL::toJava, types);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy