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

tech.kronicle.utils.ObjectReference Maven / Gradle / Ivy

Go to download

Kronicle utils library that contains utility classes for use by Kronicle and its plugins

There is a newer version: 0.1.331
Show newest version
package tech.kronicle.utils;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.function.UnaryOperator;

import static java.util.Objects.nonNull;

@NoArgsConstructor
@AllArgsConstructor
public final class ObjectReference {

    private T value;

    public T get() {
        return value;
    }

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

    public void set(UnaryOperator mapper) {
        this.value = mapper.apply(this.value);
    }

    public void clear() {
        this.value = null;
    }

    public boolean isPresent() {
        return nonNull(value);
    }

    public boolean isEmpty() {
        return !isPresent();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy