List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.apache.isis.core.progmodel.facets.object.defaults.DefaultsProviderUtil.java
public static String defaultsProviderNameFromConfiguration(final Class<?> type, final IsisConfiguration configuration) { final String key = DEFAULTS_PROVIDER_NAME_KEY_PREFIX + type.getCanonicalName() + DEFAULTS_PROVIDER_NAME_KEY_SUFFIX; final String defaultsProviderName = configuration.getString(key); return !Strings.isNullOrEmpty(defaultsProviderName) ? defaultsProviderName : null; }
From source file:adept.common.TACKBP2014EAOutput.java
/** * @param documentId May not be {@code null}. * @param scoredResponses May not have {@code null} keys or values. If any response has * a {@link TACKBP2014EventArgument#getDocumentID()} that does not * match {@code documentId}, an {@link java.lang.IllegalArgumentException} * will be thrown. * @return// www . j a va2s . com */ public static TACKBP2014EAOutput create(String documentId, Map<TACKBP2014EventArgument, Float> scoredResponses) { checkArgument(!Strings.isNullOrEmpty(documentId)); checkArgument(scoredResponses != null); for (TACKBP2014EventArgument arg : scoredResponses.keySet()) { checkArgument(arg != null); checkArgument(scoredResponses.get(arg) != null); checkArgument(documentId == arg.getDocumentID()); } return new TACKBP2014EAOutput(documentId, scoredResponses); }
From source file:com.google.cloud.hadoop.util.ConfigurationUtil.java
/** * Gets value for the given keys or throws if one or more values are not found. *///from ww w . j a v a2 s .com public static Map<String, String> getMandatoryConfig(Configuration config, List<String> keys) throws IOException { List<String> missingKeys = new ArrayList<>(); Map<String, String> values = new HashMap<>(); for (String key : keys) { String value = config.get(key); if (Strings.isNullOrEmpty(value)) { missingKeys.add(key); } else { values.put(key, value); } } if (missingKeys.size() > 0) { Joiner joiner = Joiner.on(", "); String message = "Must supply value for configuration settings: " + joiner.join(missingKeys); throw new IOException(message); } return values; }
From source file:org.cinchapi.concourse.util.Environments.java
/** * Ensure that we return the correct environment with * alphanumeric-char name for the specified {@code env}. * e.g. if {@code env} is null or empty then return the * {@link GlobalState#DEFAULT_ENVIRONMENT}. * // w w w . j av a2 s. co m * @param env * @return the environment name */ public static String sanitize(String env) { env = Strings.isNullOrEmpty(env) ? DEFAULT_ENVIRONMENT : env; env = env.replaceAll("[^A-Za-z0-9_]", ""); // ConcourseServer checks to // make sure sanitizing the // default environment won't // turn it into the empty // string return env; }
From source file:com.mvcoding.financius.core.endpoints.body.TagBody.java
@Override public void validate() throws RuntimeException { checkState(!Strings.isNullOrEmpty(title), "Title cannot be empty."); }
From source file:com.enonic.cms.core.home.HomeResolver.java
private String resolvePath() { String path = this.systemProperties.getProperty("cms.home"); if (!Strings.isNullOrEmpty(path)) { return path; }/*from w ww . ja v a2 s.c o m*/ path = this.systemProperties.getProperty("CMS_HOME"); if (!Strings.isNullOrEmpty(path)) { return path; } throw new IllegalArgumentException( "Home directory not set. Please set either [cms.home] system property or [CMS_HOME] environment variable."); }
From source file:org.obiba.mica.taxonomy.TaxonomyResolver.java
public boolean hasVocabularyName() { return !Strings.isNullOrEmpty(vocabularyName); }
From source file:com.github.dbourdette.otto.source.Event.java
public static Event fromJson(String json) throws JsonParseException, IOException { Event event = new Event(); if (Strings.isNullOrEmpty(json)) { return event; }/*from www .j a va 2s .c om*/ JsonFactory jsonFactory = new JsonFactory(); jsonFactory.setCodec(new ObjectMapper()); JsonParser jsonParser = jsonFactory.createJsonParser(json); JsonNode node = jsonParser.readValueAsTree(); Iterator<String> names = node.getFieldNames(); while (names.hasNext()) { String name = names.next(); event.parseValue(name, node.get(name).getValueAsText()); } return event; }
From source file:org.seedstack.seed.core.internal.command.ArgumentDefinition.java
String getName() {
return Strings.isNullOrEmpty(argument.name()) ? "arg" + argument.index() : argument.name();
}
From source file:org.opendaylight.yangtools.yang.data.impl.codec.CompiledPatternContext.java
CompiledPatternContext(final PatternConstraint yangConstraint) { pattern = Pattern.compile("^" + yangConstraint.getRegularExpression() + "$"); final String yangMessage = yangConstraint.getErrorMessage(); if (Strings.isNullOrEmpty(yangMessage)) { errorMessage = "Value %s does not match regular expression <" + pattern.pattern() + ">"; } else {/* w ww . jav a 2 s . co m*/ errorMessage = yangMessage; } }