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

org.jboss.as.ee.concurrent.service.DelegatingSupplier Maven / Gradle / Ivy

There is a newer version: 35.0.0.Beta1
Show newest version
/*
 * Copyright The WildFly Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package org.jboss.as.ee.concurrent.service;

import java.util.function.Supplier;

/**
 * A supplier which delegates to other supplier if it is configured.
 * @param  the type of objects that may be supplied by this supplier.
 *
 * @author Richard Opalka
 */
public final class DelegatingSupplier implements Supplier {

    private volatile Supplier delegate;

    /**
     * Gets delegating supplier value or null if supplier is not configured.
     *
     * @return delegating supplier value
     */
    @Override
    public T get() {
        final Supplier delegate = this.delegate;
        return delegate != null ? delegate.get() : null;
    }

    /**
     * Sets supplier to delegate to.
     *
     * @param delegate supplier to delegate to
     */
    public void set(final Supplier delegate) {
        this.delegate = delegate;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy