@Test public void testGetPrimitiveType() { assertEquals("I", ClassName.getPrimitiveType("java/lang/Integer")); assertEquals("F", ClassName.getPrimitiveType("java/lang/Float")); assertEquals("D", ClassName.getPrimitiveType("java/lang/Double")); assertEquals("J", ClassName.getPrimitiveType("java/lang/Long")); assertEquals("B", ClassName.getPrimitiveType("java/lang/Byte")); assertEquals("C", ClassName.getPrimitiveType("java/lang/Character")); assertEquals("S", ClassName.getPrimitiveType("java/lang/Short")); assertEquals("Z", ClassName.getPrimitiveType("java/lang/Boolean")); assertNull(ClassName.getPrimitiveType("java/lang/String")); assertNull(ClassName.getPrimitiveType("java/util/HashMap")); }
public static @CheckForNull String getPrimitiveType(@SlashedClassName String cls) { if (!cls.startsWith("java/lang/")) { return null; } cls = cls.substring(10); if ("Integer".equals(cls)) { return "I"; } if ("Float".equals(cls)) { return "F"; } if ("Double".equals(cls)) { return "D"; } if ("Long".equals(cls)) { return "J"; } if ("Byte".equals(cls)) { return "B"; } if ("Character".equals(cls)) { return "C"; } if ("Short".equals(cls)) { return "S"; } if ("Boolean".equals(cls)) { return "Z"; } return null; }
ClassName { public static @CheckForNull String getPrimitiveType(@SlashedClassName String cls) { if (!cls.startsWith("java/lang/")) { return null; } cls = cls.substring(10); if ("Integer".equals(cls)) { return "I"; } if ("Float".equals(cls)) { return "F"; } if ("Double".equals(cls)) { return "D"; } if ("Long".equals(cls)) { return "J"; } if ("Byte".equals(cls)) { return "B"; } if ("Character".equals(cls)) { return "C"; } if ("Short".equals(cls)) { return "S"; } if ("Boolean".equals(cls)) { return "Z"; } return null; } }
ClassName { public static @CheckForNull String getPrimitiveType(@SlashedClassName String cls) { if (!cls.startsWith("java/lang/")) { return null; } cls = cls.substring(10); if ("Integer".equals(cls)) { return "I"; } if ("Float".equals(cls)) { return "F"; } if ("Double".equals(cls)) { return "D"; } if ("Long".equals(cls)) { return "J"; } if ("Byte".equals(cls)) { return "B"; } if ("Character".equals(cls)) { return "C"; } if ("Short".equals(cls)) { return "S"; } if ("Boolean".equals(cls)) { return "Z"; } return null; }  }
ClassName { public static @CheckForNull String getPrimitiveType(@SlashedClassName String cls) { if (!cls.startsWith("java/lang/")) { return null; } cls = cls.substring(10); if ("Integer".equals(cls)) { return "I"; } if ("Float".equals(cls)) { return "F"; } if ("Double".equals(cls)) { return "D"; } if ("Long".equals(cls)) { return "J"; } if ("Byte".equals(cls)) { return "B"; } if ("Character".equals(cls)) { return "C"; } if ("Short".equals(cls)) { return "S"; } if ("Boolean".equals(cls)) { return "Z"; } return null; }  static boolean isMathClass(@SlashedClassName String className); static void assertIsDotted(@DottedClassName String className); static void assertIsSlashed(@SlashedClassName String className); static String toSignature(@SlashedClassName String className); static @CheckForNull String getPrimitiveType(@SlashedClassName String cls); static @CheckForNull @SlashedClassName String fromFieldSignature(String signature); @SlashedClassName @SuppressFBWarnings("TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK") static String toSlashedClassName(@SlashedClassName(when = When.UNKNOWN) String className); @DottedClassName @SuppressFBWarnings("TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK") static String toDottedClassName(@SlashedClassName(when = When.UNKNOWN) String className); static @DottedClassName String extractPackageName(@DottedClassName String className); static String extractSimpleName(@DottedClassName String className); static boolean isValidClassName(String className); static boolean isLocalOrAnonymous(String className); static boolean isAnonymous(String className); static @SlashedClassName String extractClassName(String originalName); static String extractPackagePrefix(String packageName, int count); static boolean matchedPrefixes(String[] classSearchStrings, @DottedClassName String className); static @SlashedClassName String toSlashedClassName(Class<?> class1); }
ClassName { public static @CheckForNull String getPrimitiveType(@SlashedClassName String cls) { if (!cls.startsWith("java/lang/")) { return null; } cls = cls.substring(10); if ("Integer".equals(cls)) { return "I"; } if ("Float".equals(cls)) { return "F"; } if ("Double".equals(cls)) { return "D"; } if ("Long".equals(cls)) { return "J"; } if ("Byte".equals(cls)) { return "B"; } if ("Character".equals(cls)) { return "C"; } if ("Short".equals(cls)) { return "S"; } if ("Boolean".equals(cls)) { return "Z"; } return null; }  static boolean isMathClass(@SlashedClassName String className); static void assertIsDotted(@DottedClassName String className); static void assertIsSlashed(@SlashedClassName String className); static String toSignature(@SlashedClassName String className); static @CheckForNull String getPrimitiveType(@SlashedClassName String cls); static @CheckForNull @SlashedClassName String fromFieldSignature(String signature); @SlashedClassName @SuppressFBWarnings("TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_ALWAYS_SINK") static String toSlashedClassName(@SlashedClassName(when = When.UNKNOWN) String className); @DottedClassName @SuppressFBWarnings("TQ_EXPLICIT_UNKNOWN_SOURCE_VALUE_REACHES_NEVER_SINK") static String toDottedClassName(@SlashedClassName(when = When.UNKNOWN) String className); static @DottedClassName String extractPackageName(@DottedClassName String className); static String extractSimpleName(@DottedClassName String className); static boolean isValidClassName(String className); static boolean isLocalOrAnonymous(String className); static boolean isAnonymous(String className); static @SlashedClassName String extractClassName(String originalName); static String extractPackagePrefix(String packageName, int count); static boolean matchedPrefixes(String[] classSearchStrings, @DottedClassName String className); static @SlashedClassName String toSlashedClassName(Class<?> class1);  }