List of usage examples for com.google.common.base Strings emptyToNull
@Nullable public static String emptyToNull(@Nullable String string)
From source file:net.es.nsi.pce.pf.PfUtils.java
public static String getSourceStpOrFail(P2PServiceBaseType p2ps) { Optional<String> sourceStp = Optional.fromNullable(Strings.emptyToNull(p2ps.getSourceSTP())); if (sourceStp.isPresent()) { return sourceStp.get(); }/*from www . j a va2 s.co m*/ throw Exceptions.missingParameter(Point2PointTypes.getSourceStp().getNamespace(), Point2PointTypes.getSourceStp().getType(), "null"); }
From source file:org.apache.isis.core.metamodel.facets.properties.propertylayout.LabelAtFacetOnPropertyFromLayoutProperties.java
private static LabelPosition labelPosition(Properties properties) { if (properties == null) { return null; }/*from ww w. j a v a2 s. c o m*/ String labelPosition = Strings.emptyToNull(properties.getProperty("labelPosition")); if (labelPosition == null) { // alternative key (cos I keep forgetting which to use). labelPosition = Strings.emptyToNull(properties.getProperty("labelAt")); } if (labelPosition == null) { return null; } return LabelPosition.valueOf(labelPosition); }
From source file:org.apache.isis.core.metamodel.facets.actions.layout.ActionPositionFacetOnActionFromLayoutProperties.java
private static ActionLayout.Position position(Properties properties) { if (properties == null) { return null; }/*from ww w. j av a 2 s . c om*/ String position = Strings.emptyToNull(properties.getProperty("position")); if (position == null) { position = Strings.emptyToNull(properties.getProperty("actionPosition")); } if (position == null) { return null; } return ActionLayout.Position.valueOf(position); }
From source file:org.apache.isis.core.metamodel.facets.properties.layout.RenderedAdjustedFacetOnPropertyFromLayoutProperties.java
private static boolean renderedAsDayBefore(Properties properties) { if (properties == null) { return false; }//from w ww .j a v a 2 s . c o m String renderedAsDayBefore = Strings.emptyToNull(properties.getProperty("renderedAsDayBefore")); return renderedAsDayBefore != null && Boolean.parseBoolean(renderedAsDayBefore); }
From source file:org.apache.isis.core.metamodel.facets.collections.layout.SortedByFacetOnCollectionFromLayoutProperties.java
private static Class<?> sortedBy(Properties properties) { if (properties == null) { return null; }//from w w w . ja va2 s.c o m String sortedBy = Strings.emptyToNull(properties.getProperty("sortedBy")); if (sortedBy == null) { return null; } final Class<?> sortedByClass = ClassUtil.forName(sortedBy); if (sortedByClass == Comparator.class) { return null; } return sortedByClass; }
From source file:com.googlesource.gerrit.plugins.github.git.GitHubUser.java
private static Optional<String> initFullName(GHUser gitHubUser) throws IOException { return Optional.fromNullable(gitHubUser != null ? Strings.emptyToNull(gitHubUser.getName()) : null); }
From source file:org.obiba.onyx.quartz.core.engine.questionnaire.question.Attributes.java
/** * @param namespace//w w w . ja v a 2 s. co m * @param name * @param value * @param locale * @return */ private static Attribute buildAttribute(String namespace, String name, String value, Locale locale) { Attribute.Builder attributeBuilder = Attribute.Builder.newAttribute(); attributeBuilder.withNamespace(Strings.emptyToNull(namespace)); attributeBuilder.withName(name); attributeBuilder.withValue(Strings.nullToEmpty(value)); attributeBuilder.withLocale(locale); Attribute attribute = attributeBuilder.build(); return attribute; }
From source file:org.apache.isis.core.metamodel.facets.properties.propertylayout.TypicalLengthFacetOnPropertyFromLayoutProperties.java
private static int typicalLength(Properties properties) { if (properties == null) { return -1; }//w w w . jav a 2 s .c o m String typicalLength = Strings.emptyToNull(properties.getProperty("typicalLength")); if (typicalLength == null) { return -1; } return Integer.parseInt(typicalLength); }
From source file:org.jboss.hal.core.Json.java
@SuppressWarnings("unchecked") public static List<ModelNode> parseArray(String json, Metadata metadata, Map<String, String> mappping) { if (Strings.emptyToNull(json) != null) { JsArray<JsPropertyMap<Object>> array = (JsArray<JsPropertyMap<Object>>) JSON.parse(json); if (array.length != 0) { List<ModelNode> nodes = new ArrayList<>(); for (int i = 0; i < array.length; i++) { JsPropertyMap<Object> map = array.getAt(i); ModelNode node = iterateMap(map, metadata, mappping); if (node.isDefined()) { nodes.add(node);/* w w w.j av a 2 s . com*/ } } return nodes; } else { logger.warn(EMPTY_JSON, json); return emptyList(); } } else { logger.warn(EMPTY_JSON, json); return emptyList(); } }
From source file:org.apache.isis.core.metamodel.facets.properties.propertylayout.PromptStyleFacetOnPropertyFromLayoutProperties.java
private static PromptStyle promptStyle(Properties properties) { if (properties == null) { return null; }/*w w w. j av a 2s .c o m*/ String propertyPromptStyle = Strings.emptyToNull(properties.getProperty("promptStyle")); if (propertyPromptStyle == null) { return null; } return PromptStyle.valueOf(propertyPromptStyle); }