aboutsummaryrefslogtreecommitdiffstats
path: root/bundle-plugin/src/main/java/com/yahoo/container/plugin/util/Strings.java
blob: 99ace275793775af2123ebf0c0eb0a9afe05ae0b (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 Vespa.ai. 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);
        }
    }
}