@SuppressWarnings("unchecked") public <T> T readValue(Reader src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); }
protected JavaType constructType(Type type) { return TypeFactory.defaultInstance().constructType(type); } }
/** * Returns a dictionary of string keys added to this grouper. Note that the dictionary of keySerde is spilled on * local storage whenever the inner grouper is spilled. If there are spilled dictionaries, this method loads them * from disk and returns a merged dictionary. * * @return a dictionary which is a list of unique strings */ public List<String> mergeAndGetDictionary() { final Set<String> mergedDictionary = new HashSet<>(); mergedDictionary.addAll(keySerde.getDictionary()); for (File dictFile : dictionaryFiles) { try ( final MappingIterator<String> dictIterator = spillMapper.readValues( spillMapper.getFactory().createParser(new LZ4BlockInputStream(new FileInputStream(dictFile))), spillMapper.getTypeFactory().constructType(String.class) ) ) { while (dictIterator.hasNext()) { mergedDictionary.add(dictIterator.next()); } } catch (IOException e) { throw new RuntimeException(e); } } return new ArrayList<>(mergedDictionary); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(byte[] src, int offset, int len, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src, offset, len), _typeFactory.constructType(valueTypeRef)); }
public DataCenterTypeInfoResolver() { super(TypeFactory.defaultInstance().constructType(DataCenterInfo.class), TypeFactory.defaultInstance()); }
@SuppressWarnings("unchecked") public <T> T readValue(InputStream src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); }
public InternalTypeDeserializer(Class<T> baseClass, TypeIdResolver typeIdResolver) { super(baseClass); this.typeDeserializer = new AsPropertyTypeDeserializer( TypeFactory.defaultInstance().constructType(baseClass), typeIdResolver, TYPE_PROPERTY, false, null); }
@SuppressWarnings("unchecked") public <T> T readValue(DataInput src, Class<T> valueType) throws IOException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); }
/** * Default constructor. */ public DataCenterTypeInfoResolver() { super(TypeFactory.defaultInstance().constructType(DataCenterInfo.class), TypeFactory.defaultInstance()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(Reader src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); }
/** * Static helper method that can be called to figure out type-erased * call for given JDK type. It can be called statically since type resolution * process can never change actual type-erased class; thereby static * default instance is used for determination. */ public static Class<?> rawClass(Type t) { if (t instanceof Class<?>) { return (Class<?>) t; } // Should be able to optimize bit more in future... return defaultInstance().constructType(t).getRawClass(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(InputStream src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); }
/** * Checks if the type is void. * * @param type is the type to check * @return true if the type is void */ public static boolean isVoid(Type type) { final Class<?> cls = TypeFactory.defaultInstance().constructType(type).getRawClass(); return Void.class.isAssignableFrom(cls) || Void.TYPE.isAssignableFrom(cls); }
@SuppressWarnings("unchecked") public <T> T readValue(byte[] src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); }
/** * Returns the Jackson {@link JavaType} for the specific class. * <p> * Default implementation returns {@link TypeFactory#constructType(java.lang.reflect.Type)}, but this can be * overridden in subclasses, to allow for custom generic collection handling. For instance: * * <pre class="code"> * protected JavaType getJavaType(Class<?> clazz) { * if (List.class.isAssignableFrom(clazz)) { * return TypeFactory.defaultInstance().constructCollectionType(ArrayList.class, MyBean.class); * } else { * return super.getJavaType(clazz); * } * } * </pre> * * @param clazz the class to return the java type for * @return the java type */ protected JavaType getJavaType(Class<?> clazz) { return TypeFactory.defaultInstance().constructType(clazz); } }
@SuppressWarnings("unchecked") public <T> T readValue(byte[] src, int offset, int len, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src, offset, len), _typeFactory.constructType(valueType)); }
private boolean shouldProcess(Type type) { final Class<?> cls = TypeFactory.defaultInstance().constructType(type).getRawClass(); if (cls.isPrimitive()) { return false; } String className = cls.getName(); for (String packageName : skippedPackages) { if (className.startsWith(packageName)) { return false; } } for (String classToSkip : skippedClasses) { if (className.equals(classToSkip)) { return false; } } return true; }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> T readValue(byte[] src, TypeReference valueTypeRef) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueTypeRef)); }
public static PrimitiveType fromType(Type type) { final Class<?> raw = TypeFactory.defaultInstance().constructType(type).getRawClass(); final PrimitiveType key = KEY_CLASSES.get(raw); if (key != null) { if (!customExcludedClasses.contains(raw.getName())) { return key; } } final PrimitiveType custom = customClasses.get(raw.getName()); if (custom != null) { return custom; } final PrimitiveType external = EXTERNAL_CLASSES.get(raw.getName()); if (external != null) { return external; } for (Map.Entry<Class<?>, PrimitiveType> entry : BASE_CLASSES.entrySet()) { if (entry.getKey().isAssignableFrom(raw)) { return entry.getValue(); } } return null; }
/** * Method to deserialize JSON content from given resource into given Java type. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) * @throws JsonMappingException if the input JSON structure does not match structure * expected for result type (or has other mismatch issues) */ @SuppressWarnings("unchecked") public <T> T readValue(URL src, Class<T> valueType) throws IOException, JsonParseException, JsonMappingException { return (T) _readMapAndClose(_jsonFactory.createParser(src), _typeFactory.constructType(valueType)); }