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

com.eg.google.gson.internal.Primitives Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package com.eg.google.gson.internal;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;

import static java.lang.Boolean.TYPE;
import static java.util.Collections.unmodifiableMap;


public final class Primitives
{
  private static final Map, Class> PRIMITIVE_TO_WRAPPER_TYPE;
  private static final Map, Class> WRAPPER_TO_PRIMITIVE_TYPE;

  static {
      Map, Class> primToWrap = new HashMap(16);
      Map, Class> wrapToPrim = new HashMap(16);
      add(primToWrap, wrapToPrim, TYPE, Boolean.class);
      add(primToWrap, wrapToPrim, Byte.TYPE, Byte.class);
      add(primToWrap, wrapToPrim, Character.TYPE, Character.class);
      add(primToWrap, wrapToPrim, Double.TYPE, Double.class);
      add(primToWrap, wrapToPrim, Float.TYPE, Float.class);
      add(primToWrap, wrapToPrim, Integer.TYPE, Integer.class);
      add(primToWrap, wrapToPrim, Long.TYPE, Long.class);
      add(primToWrap, wrapToPrim, Short.TYPE, Short.class);
      add(primToWrap, wrapToPrim, Void.TYPE, Void.class);
      PRIMITIVE_TO_WRAPPER_TYPE = unmodifiableMap(primToWrap);
      WRAPPER_TO_PRIMITIVE_TYPE = unmodifiableMap(wrapToPrim);
  }

  private static void add(Map, Class> forward, Map, Class> backward, Class key, Class value)
  {
     forward.put(key, value);
    backward.put(value, key);
  }



  public static boolean isPrimitive(Type type)
  {
     return PRIMITIVE_TO_WRAPPER_TYPE.containsKey(type);
  }






  public static boolean isWrapperType(Type type)
  {
     return WRAPPER_TO_PRIMITIVE_TYPE.containsKey($Gson$Preconditions.checkNotNull(type));
  }












  public static  Class wrap(Class type) {
      Class wrapped = (Class) PRIMITIVE_TO_WRAPPER_TYPE.get($Gson$Preconditions.checkNotNull(type));
      return wrapped == null ? type : wrapped;
  }











  public static  Class unwrap(Class type) {
      Class unwrapped = (Class) WRAPPER_TO_PRIMITIVE_TYPE.get($Gson$Preconditions.checkNotNull(type));
      return unwrapped == null ? type : unwrapped;
  }
}


/* Location:              D:\Android_Agent\AndroidInstrumentation\SampleApp_RE_code\NewRelic_Android_Agent_5.8.3\newrelic-android-5.8.3\lib\newrelic.android.jar!\com.google.gson\internal\Primitives.class
 * Java compiler version: 5 (49.0)
 * JD-Core Version:       0.7.1
 */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy