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

com.jsoniter.ReflectionDecoderFactory Maven / Gradle / Ivy

Go to download

jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go

The newest version!
package com.jsoniter;

import com.jsoniter.spi.ClassInfo;
import com.jsoniter.spi.Decoder;

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

class ReflectionDecoderFactory {
    public static Decoder create(ClassInfo classAndArgs) {
        Class clazz = classAndArgs.clazz;
        Type[] typeArgs = classAndArgs.typeArgs;
        if (clazz.isArray()) {
            return new ReflectionArrayDecoder(clazz);
        }
        if (Collection.class.isAssignableFrom(clazz)) {
            return new ReflectionCollectionDecoder(clazz, typeArgs);
        }
        if (Map.class.isAssignableFrom(clazz)) {
            return new ReflectionMapDecoder(clazz, typeArgs);
        }
        if (clazz.isEnum()) {
            return new ReflectionEnumDecoder(clazz);
        }
        return new ReflectionObjectDecoder(classAndArgs).create();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy