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

cn.keayuan.util.Wrapper Maven / Gradle / Ivy

The newest version!
package cn.keayuan.util;

import cn.keayuan.util.function.Consumer;

/**
 * Created by keayuan on 2022/5/6.
 *
 * @author keayuan
 */
public class Wrapper implements Runnable {
    private T value;
    private Consumer consumer;

    public Wrapper() {
    }

    public Wrapper(T t) {
        value = t;
    }

    public Wrapper(T t, Consumer run) {
        value = t;
        consumer = run;
    }

    public Wrapper(Consumer run) {
        consumer = run;
    }

    public void setValue(T t) {
        this.value = t;
    }

    public T getValue() {
        return this.value;
    }

    @Override
    public void run() {
        if (consumer != null) {
            consumer.accept(value);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy