io.camunda.tasklist.util.LazySupplier Maven / Gradle / Ivy
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
* one or more contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright ownership.
* Licensed under the Camunda License 1.0. You may not use this file
* except in compliance with the Camunda License 1.0.
*/
package io.camunda.tasklist.util;
import io.camunda.tasklist.exceptions.TasklistRuntimeException;
import java.util.function.Supplier;
import org.apache.commons.lang3.concurrent.ConcurrentException;
import org.apache.commons.lang3.concurrent.LazyInitializer;
public final class LazySupplier implements Supplier {
private final LazyInitializer lazyInitializer;
private LazySupplier(LazyInitializer lazyInitializer) {
this.lazyInitializer = lazyInitializer;
}
public static LazySupplier of(Supplier supplier) {
return new LazySupplier<>(LazyInitializer.builder().setInitializer(supplier::get).get());
}
@Override
public T get() {
try {
return lazyInitializer.get();
} catch (ConcurrentException e) {
throw new TasklistRuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy