List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.datacleaner.util.ErrorUtils.java
/** * Unwraps an exception for presentation to the user. This method will * remove unnecesary/irrelevant wrapping exceptions if possible. * * @param throwable//from w ww . ja v a2 s . com * @return */ public static Throwable unwrapForPresentation(Throwable throwable) { if (throwable == null) { return null; } while (throwable instanceof ExecutionException || throwable instanceof IllegalStateException || throwable.getClass() == RuntimeException.class) { // unwrap causes from wrapping exceptions final Throwable cause = throwable.getCause(); if (cause == null) { break; } final String message = throwable.getMessage(); if (Strings.isNullOrEmpty(message) || cause.toString().equals(message)) { // run another iteration throwable = cause; } else { break; } } return throwable; }
From source file:uk.co.bubblebearapps.motionaiclient.conversation.customsetters.CardsCustomSetters.java
@BindingAdapter(value = { "cardButtons", "cardActionHandler" }) public static void setCardButtons(ViewGroup viewGroup, List<CardButtonModel> cardButtonModels, final ConversationContract.Presenter listItemActionHandler) { recycleButtons(viewGroup);//from w w w. j a v a 2s . c o m for (CardButtonModel cardButtonModel : cardButtonModels) { if (Strings.isNullOrEmpty(cardButtonModel.getLabel())) { continue; } Button button = spareButtons.size() > 0 ? spareButtons.pop() : createNewButton(viewGroup); bindCardButtonModel(button, listItemActionHandler, cardButtonModel); viewGroup.addView(button); } }
From source file:com.b2international.snowowl.snomed.importer.rf2.refset.SnomedRefSetImporterFactory.java
public static AbstractSnomedRefSetImporter<?, ?> createRefSetImporter(final URL url, final SnomedImportContext importContext, String urlIdentifier) throws IOException { if (url == null) { return null; }/*from w w w. ja va 2s . c o m*/ String header; try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), Charsets.UTF_8))) { header = reader.readLine(); if (Strings.isNullOrEmpty(header)) { return null; } } List<String> headerElements = TAB_SPLITTER.splitToList(header); String lastColumnName = Iterables.getLast(headerElements); if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_QUERY)) { return new SnomedQueryRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_VALUE_ID)) { return new SnomedAttributeValueRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_TARGET_COMPONENT) || lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_TARGET_COMPONENT_ID)) { return new SnomedAssociationRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_MAP_TARGET)) { return new SnomedSimpleMapTypeRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_MAP_TARGET_DESCRIPTION)) { return new SnomedSimpleMapWithDescriptionRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_ACCEPTABILITY_ID)) { return new SnomedLanguageRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_REFERENCED_COMPONENT_ID)) { return new SnomedSimpleTypeRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_CORRELATION_ID)) { return new SnomedComplexMapTypeRefSetImporter(importContext, url.openStream(), false, urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_MAP_CATEGORY_ID)) { return new SnomedComplexMapTypeRefSetImporter(importContext, url.openStream(), true, urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_DESCRIPTION_LENGTH)) { return new SnomedDescriptionTypeRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_CHARACTERISTIC_TYPE_ID)) { return new SnomedConcreteDataTypeRefSetImporter(importContext, url.openStream(), true, urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_TARGET_EFFECTIVE_TIME)) { return new SnomedModuleDependencyRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_OWL_EXPRESSION)) { if (urlIdentifier.contains("Axiom")) { return new SnomedOWLAxiomRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (urlIdentifier.contains("Ontology")) { return new SnomedOWLOntologyRefSetImporter(importContext, url.openStream(), urlIdentifier); } } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_MRCM_EDITORIAL_GUIDE_REFERENCE)) { return new SnomedMRCMDomainRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equalsIgnoreCase(SnomedRf2Headers.FIELD_MRCM_RULE_REFSET_ID)) { return new SnomedMRCMModuleScopeRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (lastColumnName.equals(SnomedRf2Headers.FIELD_MRCM_CONTENT_TYPE_ID)) { if (headerElements.contains(SnomedRf2Headers.FIELD_MRCM_DOMAIN_ID)) { return new SnomedMRCMAttributeDomainRefSetImporter(importContext, url.openStream(), urlIdentifier); } else if (headerElements.contains(SnomedRf2Headers.FIELD_MRCM_RANGE_CONSTRAINT)) { return new SnomedMRCMAttributeRangeRefSetImporter(importContext, url.openStream(), urlIdentifier); } } return null; }
From source file:io.pravega.client.segment.impl.Segment.java
public static String getScopedName(String scope, String streamName, int segmentNumber) { StringBuffer sb = new StringBuffer(); if (!Strings.isNullOrEmpty(scope)) { sb.append(scope);//from w w w . j av a2s.c o m sb.append('/'); } sb.append(streamName); sb.append('/'); sb.append(segmentNumber); return sb.toString(); }
From source file:com.haulmont.cuba.core.global.Stores.java
/** * @return the list of additional data store names registered in the {@code cuba.additionalStores} app property *///w w w.java 2 s. c o m public static List<String> getAdditional() { String dbProp = AppContext.getProperty("cuba.additionalStores"); if (!Strings.isNullOrEmpty(dbProp)) return SPLITTER.splitToList(dbProp); else return Collections.emptyList(); }
From source file:org.killbill.billing.plugin.dwolla.util.DwollaPaymentPluginHelper.java
public static PaymentPluginStatus getPaymentPluginStatus(final DwollaResponsesRecord record) { if (Strings.isNullOrEmpty(record.getTransferStatus())) { return PaymentPluginStatus.UNDEFINED; } else {//from w w w. j a va2 s.c o m return getPaymentPluginStatusFromTransfer(record.getTransferStatus()); } }
From source file:org.eclipse.incquery.patternlanguage.emf.helper.GeneratorModelHelper.java
/** * Resolves the {@link Variable} using information from the {@link GenPackage}. Tries to find an appropriate * {@link GenClass} for the {@link EClassifier}. If one is found, then returns a {@link JvmTypeReference} for it's * qualified interface name.//from w w w . j a va 2 s . c om * * @param genPackage * @param classifier * @return */ public static String resolveTypeReference(GenPackage genPackage, EClassifier classifier) { GenClassifier genClassifier = findGenClassifier(genPackage, classifier); String className = null; if (!Strings.isNullOrEmpty(classifier.getInstanceClassName())) { className = classifier.getInstanceClassName(); } else if (genClassifier instanceof GenClass) { className = ((GenClass) genClassifier).getQualifiedInterfaceName(); } else if (genClassifier instanceof GenEnum) { className = ((GenEnum) genClassifier).getQualifiedInstanceClassName(); } else { //At this point, no corresponding genpackage declaration was found; creating default type className = genPackage.getInterfacePackageName() + "." + classifier.getName(); } return className; }
From source file:org.attribyte.api.pubsub.impl.Notifier.java
/** * Adds the optional signature.//from w ww. j a v a 2 s .c om * @param builder The request builder. * @param notificationContent The notification content. * @param subscription The subscription. */ protected static void addSignature(final RequestBuilder builder, final ByteString notificationContent, final Subscription subscription) { if (!Strings.isNullOrEmpty(subscription.getSecret()) && notificationContent != null) { try { String hmacSignature = HMACUtil.hexHMAC(notificationContent.toByteArray(), subscription.getSecret()); builder.addHeader("X-Hub-Signature", "sha1=" + hmacSignature); } catch (SignatureException se) { builder.addHeader("X-Hub-Signature", "sha1="); } } }
From source file:org.sonar.api.rule.RuleKey.java
/** * Create a key. Parameters are NOT null. *//*from www . j a va2 s . co m*/ public static RuleKey of(String repository, String rule) { Preconditions.checkArgument(!Strings.isNullOrEmpty(repository), "Repository must be set"); Preconditions.checkArgument(!Strings.isNullOrEmpty(rule), "Rule must be set"); return new RuleKey(repository, rule); }
From source file:org.eclipse.buildship.core.util.gradle.GradleDistributionValidator.java
/** * Creates a new {@code Validator} instance. * * @return the new instance//from w ww . j a v a 2 s . c om */ public static Validator<GradleDistributionWrapper> gradleDistributionValidator() { return new Validator<GradleDistributionWrapper>() { @Override public Optional<String> validate(GradleDistributionWrapper gradleDistribution) { GradleDistributionWrapper.DistributionType type = gradleDistribution.getType(); String configuration = gradleDistribution.getConfiguration(); if (GradleDistributionWrapper.DistributionType.LOCAL_INSTALLATION == type) { if (Strings.isNullOrEmpty(configuration)) { return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_MustBeSpecified, CoreMessages.GradleDistribution_Label_LocalInstallationDirectory)); } else if (!new File(configuration).exists()) { return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_DoesNotExist, CoreMessages.GradleDistribution_Label_LocalInstallationDirectory)); } else { return Optional.absent(); } } else if (GradleDistributionWrapper.DistributionType.REMOTE_DISTRIBUTION == type) { if (Strings.isNullOrEmpty(configuration)) { return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_MustBeSpecified, CoreMessages.GradleDistribution_Label_RemoteDistributionUri)); } else if (!isValidURI(configuration)) { return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_IsNotValid, CoreMessages.GradleDistribution_Label_RemoteDistributionUri)); } else { return Optional.absent(); } } else if (GradleDistributionWrapper.DistributionType.VERSION == type) { if (Strings.isNullOrEmpty(configuration)) { return Optional.of(NLS.bind(CoreMessages.ErrorMessage_0_MustBeSpecified, CoreMessages.GradleDistribution_Label_SpecificGradleVersion)); } else { return Optional.absent(); } } else { return Optional.absent(); } } private boolean isValidURI(String configuration) { try { new URI(configuration); return true; } catch (URISyntaxException e) { return false; } } }; }