List of usage examples for com.google.common.base Optional or
@Beta public abstract T or(Supplier<? extends T> supplier);
From source file:com.arpnetworking.configuration.BaseConfiguration.java
/** * {@inheritDoc}//from w ww . j a v a 2s. co m */ @Override public float getPropertyAsFloat(final String name, final float defaultValue) throws NumberFormatException { final Optional<Float> property = getPropertyAsFloat(name); return property.or(defaultValue); }
From source file:com.arpnetworking.configuration.BaseConfiguration.java
/** * {@inheritDoc}/*from w w w . j a va 2 s .c o m*/ */ @Override public double getPropertyAsDouble(final String name, final double defaultValue) throws NumberFormatException { final Optional<Double> property = getPropertyAsDouble(name); return property.or(defaultValue); }
From source file:org.apache.gobblin.runtime.instance.StandardGobblinInstanceLauncher.java
protected StandardGobblinInstanceLauncher(String name, Configurable instanceConf, StandardGobblinInstanceDriver.Builder driverBuilder, Optional<MetricContext> metricContext, Optional<Logger> log, SharedResourcesBroker<GobblinScopeTypes> instanceBroker) { _log = log.or(LoggerFactory.getLogger(getClass())); _name = name;//w w w. ja v a2 s.c o m _instanceConf = instanceConf; _driver = driverBuilder.withInstanceEnvironment(this).build(); _instrumentationEnabled = metricContext.isPresent(); _metricContext = metricContext.orNull(); _instanceBroker = instanceBroker; }
From source file:org.jclouds.azurecompute.arm.compute.strategy.CreateResourcesThenCreateNodes.java
private void generatePasswordIfNoneProvided(Template template) { TemplateOptions options = template.getOptions(); if (options.getLoginPassword() == null) { Optional<String> passwordOptional = template.getImage().getDefaultCredentials().getOptionalPassword(); options.overrideLoginPassword(passwordOptional.or(passwordGenerator.generate())); }/*from w w w. j a va 2 s . com*/ }
From source file:com.kryptnostic.rhizome.configuration.amazon.AwsLaunchConfiguration.java
@JsonCreator public AwsLaunchConfiguration(@JsonProperty(BUCKET_FIELD) String bucket, @JsonProperty(FOLDER_FIELD) Optional<String> folder, @JsonProperty(REGION_FIELD) Optional<String> region) { Preconditions.checkArgument(StringUtils.isNotBlank(bucket), "S3 bucket for configuration must be specified."); this.bucket = bucket; String rawFolder = folder.or(DEFAULT_FOLDER); while (StringUtils.endsWith(rawFolder, "/")) { StringUtils.removeEnd(rawFolder, "/"); }/*from w w w . jav a 2 s . c om*/ // We shouldn't prefix if (StringUtils.isNotBlank(rawFolder)) { this.folder = rawFolder + "/"; } else { this.folder = rawFolder; } this.region = region.isPresent() ? Optional.of(Regions.fromName(region.get())) : Optional.absent(); }
From source file:com.arpnetworking.configuration.BaseConfiguration.java
/** * {@inheritDoc}/*ww w. ja v a 2s. com*/ */ @Override public boolean getPropertyAsBoolean(final String name, final boolean defaultValue) { final Optional<Boolean> property = getPropertyAsBoolean(name); return property.or(defaultValue); }
From source file:com.arpnetworking.configuration.BaseConfiguration.java
/** * {@inheritDoc}/*from ww w. j a va 2 s. c om*/ */ @Override public int getPropertyAsInteger(final String name, final int defaultValue) throws NumberFormatException { final Optional<Integer> property = getPropertyAsInteger(name); return property.or(defaultValue); }
From source file:org.jage.platform.config.xml.readers.CollectionDefinitionReader.java
@Override public CollectionDefinition read(Element element) throws ConfigurationException { String nameAttribute = getRequiredAttribute(element, NAME); Optional<String> typeAttribute = getOptionalAttribute(element, TYPE); Optional<String> isSingletonAttribute = getOptionalAttribute(element, IS_SINGLETON); CollectionDefinition definition = new CollectionDefinition(nameAttribute, collectionClass, toClass(typeAttribute.or(getDefaultType())), toBoolean(isSingletonAttribute.or(getDefaultIsSingleton()))); for (Element child : getChildrenIncluding(element, REFERENCE, VALUE)) { IArgumentDefinition value = argumentReader.read(child); definition.addItem(value);/*from ww w . j ava 2s . c o m*/ } // FIXME: Backward compatibility. Remove in future ticket for (Element child : getChildrenExcluding(element, REFERENCE, VALUE)) { IComponentDefinition innerDefinition = instanceReader.read(child); definition.addInnerComponentDefinition(innerDefinition); } return definition; }
From source file:org.eclipse.buildship.ui.wizard.project.ProjectImportWizardController.java
private GradleDistributionWrapper createGradleDistribution(Optional<String> gradleDistributionType, Optional<String> gradleDistributionConfiguration) { DistributionType distributionType = DistributionType .valueOf(gradleDistributionType.or(DistributionType.WRAPPER.name())); String distributionConfiguration = gradleDistributionConfiguration.orNull(); return GradleDistributionWrapper.from(distributionType, distributionConfiguration); }
From source file:org.jmingo.query.QueryManager.java
private AtomicReference<QuerySet> getQuerySetRef(Path path) { Optional<AtomicReference<QuerySet>> result = Iterables.tryFind(querySetRegistry, querySet -> querySet.get().getPath().equals(path)); return result.or(new AtomicReference<>(null)); }