io.github.stewseo.client.json.LazyDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yelp-fusion-client Show documentation
Show all versions of yelp-fusion-client Show documentation
java client to build api objects, handle http transport, and parse/deserialize/serialize json to/from json
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