You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
376 B
15 lines
376 B
/* © SRSoftware 2024 */ |
|
package de.srsoftware.utils; |
|
import static java.util.Optional.empty; |
|
|
|
import java.util.Optional; |
|
|
|
public class Optionals { |
|
public static <T> Optional<T> nullable(T val) { |
|
return Optional.ofNullable(val); |
|
} |
|
|
|
public static Optional<String> emptyIfBlank(String text) { |
|
return text == null || text.isBlank() ? empty() : nullable(text.trim()); |
|
} |
|
}
|
|
|