List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.n52.shetland.ogc.PhenomenonNameDescriptionProvider.java
default boolean isSetObservablePropertyName(String observableProperty) { return !Strings.isNullOrEmpty(getObservablePropertyName(observableProperty)); }
From source file:com.appdynamics.monitors.muleesb.JMXUtil.java
private static JMXConnector connect(String host, int port, String username, String password) throws IOException { String jmxUrl = buildUrl(host, port); JMXServiceURL url = new JMXServiceURL(jmxUrl); final Map<String, Object> env = new HashMap<String, Object>(); JMXConnector connector = null; if (!Strings.isNullOrEmpty(username)) { env.put(JMXConnector.CREDENTIALS, new String[] { username, password }); connector = JMXConnectorFactory.connect(url, env); } else {/* www.j a va 2s. c o m*/ connector = JMXConnectorFactory.connect(url); } return connector; }
From source file:com.mvcoding.financius.core.endpoints.body.RegisterUserBody.java
@Override public void validate() throws RuntimeException { checkState(!Strings.isNullOrEmpty(googleId), "Google Id cannot be empty."); }
From source file:com.b2international.snowowl.datastore.request.BranchRebaseRequest.java
private static String commitMessageOrDefault(final String sourcePath, final String targetPath, final String commitMessage) { return !Strings.isNullOrEmpty(commitMessage) ? commitMessage : String.format("Rebase branch '%s' on '%s'", targetPath, sourcePath); }
From source file:com.zimbra.cs.mailbox.util.TagUtil.java
@Deprecated public static String[] tagIdStringToNames(Mailbox mbox, OperationContext octxt, String tagIdString) throws ServiceException { if (Strings.isNullOrEmpty(tagIdString)) { return NO_TAGS; }/*from w w w. j a va2 s .c o m*/ List<String> tags = Lists.newArrayList(); for (String tagId : Splitter.on(',').omitEmptyStrings().trimResults().split(tagIdString)) { try { tags.add(mbox.getTagById(octxt, Integer.parseInt(tagId)).getName()); } catch (NumberFormatException nfe) { throw ServiceException.INVALID_REQUEST("invalid tag ID string: " + tagIdString, nfe); } } return tags.toArray(new String[tags.size()]); }
From source file:com.google.shipshape.util.rpc.HttpTransport.java
/** Returns a {@link Connection} to the given host over HTTP. */ public static Connection newHttpConnection(String host, int port) { Preconditions.checkArgument(!Strings.isNullOrEmpty(host), "host must be non-empty"); Preconditions.checkArgument(port > 0, "port must be positive"); try {//from w w w. ja v a 2 s . com return newHttpConnection(new URL("http", host, port, "/")); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } }
From source file:org.apache.isis.core.metamodel.facets.object.encodeable.EncoderDecoderUtil.java
public static String encoderDecoderNameFromConfiguration(final Class<?> type, final IsisConfiguration configuration) { final String key = ENCODER_DECODER_NAME_KEY_PREFIX + type.getCanonicalName() + ENCODER_DECODER_NAME_KEY_SUFFIX; final String encoderDecoderName = configuration.getString(key); return !Strings.isNullOrEmpty(encoderDecoderName) ? encoderDecoderName : null; }
From source file:caveworld.core.ConfigHelper.java
public static Collection<ItemStack> getItemsFromStrings(Collection<ItemStack> list, String... strings) { for (String str : strings) { if (!Strings.isNullOrEmpty(str)) { str = str.trim();//from ww w . j av a2 s . c o m if (!str.contains(":")) { str = "minecraft:" + str; } if (str.indexOf(':') != str.lastIndexOf(':')) { int i = str.lastIndexOf(':'); Item item = GameData.getItemRegistry().getObject(str.substring(0, i)); if (item != null) { list.add(new ItemStack(item, 1, Integer.parseInt(str.substring(i + 1)))); } } else { Item item = GameData.getItemRegistry().getObject(str); if (item != null) { list.add(new ItemStack(item)); } } } } return list; }
From source file:org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException.java
public NoShardLeaderException(String message, String shardName) { super(String.format("%sShard %s currently has no leader. Try again later.", (Strings.isNullOrEmpty(message) ? "" : message + ". "), shardName)); }
From source file:com.arto.event.config.ConfigManager.java
public static int getInt(String name, int value) { String val = ConfigManager.getInstance().getValue(name); int result = value; if (!Strings.isNullOrEmpty(val)) { result = Integer.parseInt(val); }/*from w ww .j a va 2 s . co m*/ log.debug("Load property '" + name + "' = " + result); return result; }