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

io.soffa.foundation.commons.Value Maven / Gradle / Ivy

The newest version!
package io.soffa.foundation.commons;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Optional;

@Data
@NoArgsConstructor
public class Value {

    private Object obj;

    public Value(Object value) {
        this.obj = value;
    }

    public static  T getOrElse(T value, T defaultValue) {
        if (value instanceof String) {
            if (TextUtil.isEmpty((String) value)) {
                return defaultValue;
            }
            return value;
        }
        return Optional.ofNullable(value).orElse(defaultValue);
    }

    public boolean isNull() {
        return obj == null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy