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

com.jsoniter.output.DefaultMapKeyEncoder Maven / Gradle / Ivy

Go to download

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

There is a newer version: 0.9.23
Show newest version
package com.jsoniter.output;

import com.jsoniter.spi.*;

import java.lang.reflect.Type;

class DefaultMapKeyEncoder implements MapKeyEncoder {

    public static MapKeyEncoder registerOrGetExisting(Type mapKeyType) {
        String cacheKey = JsoniterSpi.getMapKeyEncoderCacheKey(mapKeyType);
        MapKeyEncoder mapKeyEncoder = JsoniterSpi.getMapKeyEncoder(cacheKey);
        if (null != mapKeyEncoder) {
            return mapKeyEncoder;
        }
        mapKeyEncoder = new DefaultMapKeyEncoder();
        JsoniterSpi.addNewMapEncoder(cacheKey, mapKeyEncoder);
        return mapKeyEncoder;
    }

    @Override
    public String encode(Object mapKey) {
        return mapKey.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy