
com.nhl.link.rest.parser.converter.LazyConverter Maven / Gradle / Ivy
package com.nhl.link.rest.parser.converter;
import com.fasterxml.jackson.databind.JsonNode;
import java.util.function.Supplier;
public class LazyConverter implements JsonValueConverter {
private final Supplier> delegateSupplier;
private volatile JsonValueConverter delegate;
private final Object lock;
public LazyConverter(Supplier> delegateSupplier) {
this.delegateSupplier = delegateSupplier;
this.lock = new Object();
}
@Override
public T value(JsonNode node) {
if (delegate == null) {
synchronized (lock) {
if (delegate == null) {
delegate = delegateSupplier.get();
}
}
}
return delegate.value(node);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy