, Class>> backward, Class> key, Class> value) {
- forward.put(key, value);
- backward.put(value, key);
- }
-
- /**
- * Returns true if this type is a primitive.
- */
- public static boolean isPrimitive(Type type) {
- return PRIMITIVE_TO_WRAPPER_TYPE.containsKey(type);
- }
-
- /**
- * Returns {@code true} if {@code type} is one of the nine primitive-wrapper
- * types, such as {@link Integer}.
- *
- * @see Class#isPrimitive
- */
- public static boolean isWrapperType(Type type) {
- return WRAPPER_TO_PRIMITIVE_TYPE.containsKey(checkNotNull(type));
- }
-
- /**
- * Returns the corresponding wrapper type of {@code type} if it is a
- * primitive type; otherwise returns {@code type} itself. Idempotent.
- *
- *
- * wrap(int.class) == Integer.class
- * wrap(Integer.class) == Integer.class
- * wrap(String.class) == String.class
- *
- */
- public static Class wrap(Class type) {
- // cast is safe: long.class and Long.class are both of type Class
- @SuppressWarnings("unchecked")
- Class wrapped = (Class) PRIMITIVE_TO_WRAPPER_TYPE
- .get(checkNotNull(type));
- return (wrapped == null) ? type : wrapped;
- }
-
- /**
- * Returns the corresponding primitive type of {@code type} if it is a
- * wrapper type; otherwise returns {@code type} itself. Idempotent.
- *
- *
- * unwrap(Integer.class) == int.class
- * unwrap(int.class) == int.class
- * unwrap(String.class) == String.class
- *
- */
- public static Class unwrap(Class type) {
- // cast is safe: long.class and Long.class are both of type Class
- @SuppressWarnings("unchecked")
- Class unwrapped = (Class) WRAPPER_TO_PRIMITIVE_TYPE
- .get(checkNotNull(type));
- return (unwrapped == null) ? type : unwrapped;
- }
-
- public static T checkNotNull(T obj) {
- if (obj == null) {
- throw new NullPointerException();
- }
- return obj;
- }
-}
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java
index f4bb07f3..2665dc21 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java
@@ -426,7 +426,7 @@ public class StructureModifier {
Class> type = field.getType();
// First, ignore primitive fields
- if (!PrimitiveUtils.isPrimitive(type)) {
+ if (!type.isPrimitive()) {
// Next, see if we actually can generate a default value
if (generator.getDefault(type) != null) {
// If so, require it
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java
index fde9de08..10ceaa72 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java
@@ -25,9 +25,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.comphenix.protocol.reflect.PrimitiveUtils;
import com.comphenix.protocol.reflect.StructureModifier;
import com.google.common.base.Objects;
+import com.google.common.primitives.Primitives;
import net.sf.cglib.asm.*;
@@ -306,7 +306,7 @@ public final class StructureCompiler {
for (int i = 0; i < fields.size(); i++) {
Class> outputType = fields.get(i).getType();
- Class> inputType = PrimitiveUtils.wrap(outputType);
+ Class> inputType = Primitives.wrap(outputType);
String typeDescriptor = Type.getDescriptor(outputType);
String inputPath = inputType.getName().replace('.', '/');
@@ -323,7 +323,7 @@ public final class StructureCompiler {
mv.visitVarInsn(Opcodes.ALOAD, 3);
mv.visitVarInsn(Opcodes.ALOAD, 2);
- if (!PrimitiveUtils.isPrimitive(outputType))
+ if (!outputType.isPrimitive())
mv.visitTypeInsn(Opcodes.CHECKCAST, inputPath);
else
boxingHelper.unbox(Type.getType(outputType));
diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java
index 526846a0..5563acc6 100644
--- a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java
+++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java
@@ -21,8 +21,8 @@ import java.lang.reflect.Array;
import javax.annotation.Nullable;
-import com.comphenix.protocol.reflect.PrimitiveUtils;
import com.google.common.base.Defaults;
+import com.google.common.primitives.Primitives;
/**
* Provides constructors for primtive types, wrappers, arrays and strings.
@@ -58,10 +58,10 @@ public class PrimitiveGenerator implements InstanceProvider {
@Override
public Object create(@Nullable Class> type) {
- if (PrimitiveUtils.isPrimitive(type)) {
+ if (type.isPrimitive()) {
return Defaults.defaultValue(type);
- } else if (PrimitiveUtils.isWrapperType(type)) {
- return Defaults.defaultValue(PrimitiveUtils.unwrap(type));
+ } else if (Primitives.isWrapperType(type)) {
+ return Defaults.defaultValue(Primitives.unwrap(type));
} else if (type.isArray()) {
Class> arrayType = type.getComponentType();
return Array.newInstance(arrayType, 0);