Example usage for com.google.common.base Strings nullToEmpty

List of usage examples for com.google.common.base Strings nullToEmpty

Introduction

In this page you can find the example usage for com.google.common.base Strings nullToEmpty.

Prototype

public static String nullToEmpty(@Nullable String string) 

Source Link

Document

Returns the given string if it is non-null; the empty string otherwise.

Usage

From source file:com.kegare.friendlymobs.util.Version.java

private static void initialize() {
    CURRENT = Optional.of(Strings.nullToEmpty(FriendlyMobs.metadata.version));
    LATEST = Optional.fromNullable(CURRENT.orNull());

    File file = FriendlyUtils.getModContainer().getSource();

    if (file != null && file.exists()) {
        if (file.isFile()) {
            if (StringUtils.endsWithIgnoreCase(FilenameUtils.getBaseName(file.getName()), "dev")) {
                DEV_DEBUG = true;// w w  w  . ja v  a2 s .  co m
            }
        } else {
            DEV_DEBUG = true;
        }
    } else if (!FMLForgePlugin.RUNTIME_DEOBF) {
        DEV_DEBUG = true;
    }

    if (StringUtils.endsWithIgnoreCase(getCurrent(), "dev")) {
        DEV_DEBUG = true;
    } else if (DEV_DEBUG) {
        FriendlyMobs.metadata.version += "-dev";
    }
}

From source file:org.azolla.model.XmlConfigures.java

@SuppressWarnings("unchecked")
public static <T> T unmarshal(Class<T> clazz, String filePath) {
    try {/*from   www  .j av  a2  s.  c om*/
        return (T) getJAXBContext(clazz).createUnmarshaller()
                .unmarshal(new File(Strings.nullToEmpty(filePath)));
    } catch (Exception e) {
        return null;
    }
}

From source file:io.macgyver.plugin.cloud.aws.AWSServiceFactory.java

public static List<Regions> splitToRegionList(String input) {
    List<Regions> regionList = Lists.newArrayList();
    Splitter.onPattern("(,|\\s|;)").omitEmptyStrings().trimResults().splitToList(Strings.nullToEmpty(input))
            .forEach(name -> {/*from w  ww  .java  2 s .  c  om*/
                try {
                    regionList.add(Regions.fromName(name));
                } catch (RuntimeException e) {
                    LoggerFactory.getLogger(AWSServiceFactory.class).warn("could not configure region: " + name,
                            e);
                }
            });
    return regionList;
}

From source file:com.kegare.caveworld.util.Version.java

private static void initialize() {
    CURRENT = Optional.of(Strings.nullToEmpty(Caveworld.metadata.version));
    LATEST = Optional.fromNullable(CURRENT.orNull());

    ModContainer mod = CaveUtils.getModContainer();
    File file = mod == null ? null : mod.getSource();

    if (file != null && file.exists()) {
        if (file.isFile()) {
            String name = FilenameUtils.getBaseName(file.getName());

            if (StringUtils.endsWithIgnoreCase(name, "dev")) {
                DEV_DEBUG = true;/*from   w w  w  .j av a2 s.  c  o m*/
            }
        } else if (file.isDirectory()) {
            DEV_DEBUG = true;
        }
    } else if (!FMLForgePlugin.RUNTIME_DEOBF) {
        DEV_DEBUG = true;
    }

    if (Caveworld.metadata.version.endsWith("dev")) {
        DEV_DEBUG = true;
    } else if (DEV_DEBUG) {
        Caveworld.metadata.version += "-dev";
    }
}

From source file:de.m0ep.socc.core.utils.StringUtils.java

/**
 * User JSoup to remove all HTML tags from a string If value is empty, it
 * will be converted to an empty string.
 * /*from   w w  w.  j a  va 2s .  c o m*/
 * @param value
 *            String to strip
 * @return String without HTML tags
 */
public static String stripHTML(final String value) {
    return Jsoup.parse(Strings.nullToEmpty(value)).text();
}

From source file:org.trustedanalytics.servicebroker.hdfs.config.catalog.BrokerPlans.java

public static boolean isEncrypted(String planId) {
    return Strings.nullToEmpty(planId).toLowerCase().contains(ENCRYPTED_KEY);
}

From source file:org.apache.mahout.text.LuceneSeqFileHelper.java

public static void populateValues(Document document, Text theValue, List<String> fields) {

    StringBuilder valueBuilder = new StringBuilder();
    for (int i = 0; i < fields.size(); i++) {
        String field = fields.get(i);
        String fieldValue = document.get(field);
        if (isNotBlank(fieldValue)) {
            valueBuilder.append(fieldValue);
            if (i != fields.size() - 1) {
                valueBuilder.append(SEPARATOR_FIELDS);
            }//from w  w  w.  j a  va  2s .c o m
        }
    }
    theValue.set(Strings.nullToEmpty(valueBuilder.toString()));
}

From source file:hu.bme.mit.massif.common.NamingUtil.java

public static String getShortNameOfNamedElement(EObject massifElement) {
    String result = "";
    /* SIMULINK */
    if (massifElement instanceof SimulinkElement) {
        result = ((SimulinkElement) massifElement).getName();
    } else if (massifElement instanceof Property) {
        result = ((Property) massifElement).getName();
    } else if (massifElement instanceof BusSignalMapping) {
        EObject parent = massifElement.eContainer();
        if (parent instanceof BusSelector) {
            BusSelector busSelector = (BusSelector) parent;
            result = "BusSignalMapping " + busSelector.getMappings().indexOf(massifElement);
        } else {//ww w.  j a  v a2 s. co  m
            result = "BusSignalMapping";
        }
    } else {
        result = massifElement.toString();
    }
    return Strings.nullToEmpty(result);
}

From source file:pl.porannajava.javnysejm.support.StringConverter.java

private static String normalizeString(String input) {
    return Strings.nullToEmpty(input).trim();
}

From source file:org.mythtv.services.api.ETagInfo.java

public ETagInfo(String eTag) {
    this.eTag = Strings.nullToEmpty(eTag);
    newETag = false;
}