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

io.github.stewseo.client.json.LazyDeserializer Maven / Gradle / Ivy

Go to download

java client to build api objects, handle http transport, and parse/deserialize/serialize json to/from json

There is a newer version: 1.8.0
Show newest version
package io.github.stewseo.client.json;

import java.util.function.Supplier;

public class LazyDeserializer extends DelegatingDeserializer.SameType {

    private final Supplier> ctor;
    private volatile JsonpDeserializer deserializer = null;

    public LazyDeserializer(Supplier> ctor) {
        this.ctor = ctor;
    }

    protected JsonpDeserializer unwrap() {
        // See SEI CERT LCK10-J https://wiki.sei.cmu.edu/confluence/x/6zdGBQ
        JsonpDeserializer d = deserializer;
        if (d != null) {
            return d;
        } else {
            synchronized (this) {
                if (deserializer == null) {
                    deserializer = ctor.get();
                }
            }
            return deserializer;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy