TypeCodes { public static int decodeType(int split, String jsonString) { if (split == -1 || split > jsonString.length()) { return PropertyType.UNDEFINED; } else { Integer type = CODE2TYPE.get(jsonString.substring(0, split)); return type == null ? PropertyType.UNDEFINED : type; } } private  TypeCodes(); static String encode(int propertyType, String propertyName); static int split(String jsonString); static int decodeType(int split, String jsonString); static String decodeName(int split, String jsonString); static final String EMPTY_ARRAY; }
@Test public void testDecodeType() { String strFoo = "str:foo"; assertEquals(PropertyType.STRING, TypeCodes.decodeType(TypeCodes.split(strFoo), strFoo)); String str = "str:"; assertEquals(PropertyType.STRING, TypeCodes.decodeType(TypeCodes.split(str), str)); String any = "any"; assertEquals(PropertyType.UNDEFINED, TypeCodes.decodeType(TypeCodes.split(any), any)); String empty = ""; assertEquals(PropertyType.UNDEFINED, TypeCodes.decodeType(TypeCodes.split(empty), empty)); }