List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:org.apache.provisionr.amazon.activities.TerminateInstances.java
@Override public void execute(AmazonEC2 client, Pool pool, DelegateExecution execution) { @SuppressWarnings("unchecked") Optional<List<String>> instanceIds = Optional .fromNullable((List<String>) execution.getVariable(ProcessVariables.INSTANCE_IDS)); LOG.info(">> Terminating instances: {}", instanceIds); if (instanceIds.isPresent() && instanceIds.get().size() > 0) { client.terminateInstances(new TerminateInstancesRequest().withInstanceIds(instanceIds.get())); }/*from w w w . jav a2 s . co m*/ }
From source file:io.crate.planner.node.dml.InsertFromSubQuery.java
public InsertFromSubQuery(Plan innerPlan, @Nullable MergePhase handlerMergeNode, UUID id) { this.innerPlan = innerPlan; this.handlerMergeNode = Optional.fromNullable(handlerMergeNode); this.id = id; }
From source file:com.cloudera.exhibit.core.simple.SimpleExhibitStore.java
@Override public Optional<Exhibit> find(ExhibitId id) { if (!entity.equals(id.getEntity())) { return Optional.absent(); }/* ww w. j a v a2 s. c o m*/ return Optional.fromNullable(exhibits.get(id.getId())); }
From source file:org.geogit.osm.internal.history.ChangesetScanner.java
public Optional<Changeset> parse(InputStream changesetStream) throws XMLStreamException { XMLStreamReader reader;//from ww w . j a v a2 s . c o m reader = XMLInputFactory.newFactory().createXMLStreamReader(changesetStream, "UTF-8"); Changeset changeset = parse(reader); return Optional.fromNullable(changeset); }
From source file:io.crate.sql.tree.Update.java
public Update(Relation relation, List<Assignment> assignments, @Nullable Expression where) { Preconditions.checkNotNull(relation, "relation is null"); Preconditions.checkNotNull(assignments, "assignments are null"); this.relation = relation; this.assignments = assignments; this.where = Optional.fromNullable(where); }
From source file:org.apache.usergrid.corepersistence.export.ExportRequestBuilderImpl.java
/*** * * @param applicationId The application id * @return//from ww w .j av a 2 s. c om */ @Override public ExportRequestBuilder withApplicationId(final UUID applicationId) { this.withApplicationId = Optional.fromNullable(applicationId); return this; }
From source file:com.wealdtech.utils.RequestHint.java
@JsonCreator public RequestHint(@JsonProperty("latitude") final Integer latitude, @JsonProperty("longitude") final Integer longitude, @JsonProperty("altitude") final Float altitude, @JsonProperty("address") final InetAddress address, @JsonProperty("useragent") final String userAgent) { this.latitude = Optional.fromNullable(latitude); this.longitude = Optional.fromNullable(longitude); this.altitude = Optional.fromNullable(altitude); this.address = Optional.fromNullable(address); this.userAgent = Optional.fromNullable(userAgent); }
From source file:com.spotify.heroic.suggest.MatchOptions.java
@JsonCreator public MatchOptions(@JsonProperty("fuzzy") boolean fuzzy, @JsonProperty("fuzzyPrefixLength") Integer fuzzyPrefixLength, @JsonProperty("fuzzyMaxExpansions") Integer fuzzyMaxExpansions, @JsonProperty("tokenize") boolean tokenize) { this.fuzzy = Optional.fromNullable(fuzzy).or(DEFAULT_FUZZY); this.fuzzyPrefixLength = Optional.fromNullable(fuzzyPrefixLength).or(DEFAULT_FUZZY_PREFIX_LENGTH); this.fuzzyMaxExpansions = Optional.fromNullable(fuzzyMaxExpansions).or(DEFAULT_FUZZY_MAX_EXPANSIONS); this.tokenize = Optional.fromNullable(tokenize).or(DEFAULT_TOKENIZE); }
From source file:org.jclouds.route53.domain.ResourceRecordSetIterable.java
private ResourceRecordSetIterable(Iterable<ResourceRecordSet> items, @Nullable NextRecord nextRecord) { this.items = checkNotNull(items, "items"); this.nextRecord = Optional.fromNullable(nextRecord); }
From source file:com.gradleware.tooling.toolingmodel.repository.internal.DefaultOmniBuildInvocationsContainer.java
@Override public Optional<OmniBuildInvocations> get(Path projectPath) { return Optional.fromNullable(this.buildInvocationsPerProject.get(projectPath)); }