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

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

Introduction

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

Prototype

@Nullable
public static String emptyToNull(@Nullable String string) 

Source Link

Document

Returns the given string if it is nonempty; null otherwise.

Usage

From source file:org.apache.isis.core.metamodel.facets.properties.layout.CssClassFacetOnPropertyFromLayoutProperties.java

private static String cssClass(Properties properties) {
    if (properties == null) {
        return null;
    }//from ww w . j a v a  2  s .  co m
    return Strings.emptyToNull(properties.getProperty("cssClass"));
}

From source file:org.apache.isis.core.metamodel.facets.properties.propertylayout.MultiLineFacetOnPropertyFromLayoutProperties.java

private static int multiLine(Properties properties) {
    if (properties == null) {
        return -1;
    }//from   www .ja  v  a2  s.c  o m
    String multiLine = Strings.emptyToNull(properties.getProperty("multiLine"));
    if (multiLine == null) {
        return -1;
    }
    return Integer.parseInt(multiLine);
}

From source file:org.apache.isis.core.metamodel.facets.properties.propertylayout.UnchangingFacetOnPropertyFromLayoutProperties.java

private static boolean unchanging(Properties properties) {
    if (properties == null) {
        return false;
    }/*from   w w  w  .j a v  a 2  s.  c om*/
    String unchanging = Strings.emptyToNull(properties.getProperty("unchanging"));
    return unchanging != null && Boolean.parseBoolean(unchanging);
}

From source file:org.apache.isis.core.metamodel.facets.properties.propertylayout.DescribedAsFacetOnPropertyFromLayoutProperties.java

private static String describedAs(Properties properties) {
    if (properties == null) {
        return null;
    }/* ww  w  .  jav  a  2 s .c o m*/
    String describedAs = Strings.emptyToNull(properties.getProperty("describedAs"));
    if (describedAs == null) {
        // alternate key
        describedAs = Strings.emptyToNull(properties.getProperty("description"));
    }
    return describedAs;
}

From source file:org.apache.isis.core.metamodel.facets.collections.layout.CssClassFacetOnCollectionFromLayoutProperties.java

private static String cssClass(Properties properties) {
    if (properties == null) {
        return null;
    }// w  ww .ja v  a 2s  .  c om
    final String cssClass = properties.getProperty("cssClass");
    return Strings.emptyToNull(cssClass);
}

From source file:org.apache.isis.core.metamodel.facets.collections.layout.HiddenFacetOnCollectionFromLayoutProperties.java

private static Where hidden(Properties properties) {
    if (properties == null) {
        return null;
    }/*from www.  j  av  a2  s. c o  m*/
    String hidden = Strings.emptyToNull(properties.getProperty("hidden"));
    if (hidden == null) {
        return null;
    }
    return Where.valueOf(hidden);
}

From source file:com.google.gerrit.pgm.init.JDBCInitializer.java

@Override
public void initConfig(Section database) {
    boolean hasUrl = Strings.emptyToNull(database.get("url")) != null;
    database.string("URL", "url", null);
    guessDriver(database);//from w  w  w .  j a v a 2  s  .  c om
    database.string("Driver class name", "driver", null);
    database.string("Database username", "username", hasUrl ? null : username());
    database.password("username", "password");
}

From source file:org.apache.isis.core.metamodel.facets.actions.layout.BookmarkPolicyFacetOnActionFromLayoutProperties.java

private static BookmarkPolicy hidden(Properties properties) {
    if (properties == null) {
        return null;
    }//from w w w .j a  v  a2s  .c o  m
    String bookmarking = Strings.emptyToNull(properties.getProperty("bookmarking"));
    if (bookmarking == null) {
        // alternate key
        bookmarking = Strings.emptyToNull(properties.getProperty("bookmarkable"));
        return null;
    }
    return BookmarkPolicy.valueOf(bookmarking);
}

From source file:org.apache.isis.core.metamodel.facets.collections.layout.RenderFacetOnCollectionFromLayoutProperties.java

private static RenderType render(Properties properties) {
    if (properties == null) {
        return null;
    }//ww w.  j a  v  a2s. co  m
    String renderType = Strings.emptyToNull(properties.getProperty("render"));
    if (renderType == null) {
        return null;
    }
    return RenderType.valueOf(renderType);
}

From source file:org.apache.isis.core.metamodel.facets.collections.layout.NamedFacetOnCollectionFromLayoutProperties.java

private static String named(Properties properties) {
    if (properties == null) {
        return null;
    }/*from w  ww  .ja va  2  s.c  o m*/
    String named = Strings.emptyToNull(properties.getProperty("named"));
    if (named == null) {
        // alternate key
        named = Strings.emptyToNull(properties.getProperty("name"));
    }
    return named;
}