summaryrefslogtreecommitdiffstats
path: root/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/Strings.java
blob: 15bdfb153ad3152f443e9fd0a9f0ec95433c2ee6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.plugin.util;

import java.util.Optional;

/**
 * @author Tony Vaagenes
 * @author ollivir
 */
public class Strings {
    public static String replaceEmptyString(String s, String replacement) {
        if (s == null || s.isEmpty()) {
            return replacement;
        } else {
            return s;
        }
    }

    public static Optional<String> noneIfEmpty(String s) {
        if (s == null || s.isEmpty()) {
            return Optional.empty();
        } else {
            return Optional.of(s);
        }
    }
}