List of usage examples for com.google.common.base Optional orNull
@Nullable public abstract T orNull();
From source file:com.github.tomakehurst.wiremock.admin.model.SingleServedStubResult.java
public static SingleServedStubResult fromOptional(Optional<ServeEvent> servedStub) { return new SingleServedStubResult(servedStub.orNull()); }
From source file:com.github.tomakehurst.wiremock.admin.model.SingleStubMappingResult.java
public static SingleStubMappingResult fromOptional(Optional<StubMapping> optional) { return new SingleStubMappingResult(optional.orNull()); }
From source file:gobblin.writer.partitioner.TimeBasedAvroWriterPartitioner.java
/** * Check if the partition column value is present and is a Long object. Otherwise, use current system time. */// w w w. ja v a 2 s . c o m private static long getRecordTimestamp(Optional<Object> writerPartitionColumnValue) { return writerPartitionColumnValue.orNull() instanceof Long ? (Long) writerPartitionColumnValue.get() : System.currentTimeMillis(); }
From source file:org.eclipse.recommenders.codesearch.rcp.index.indexer.BindingHelper.java
public static Optional<String> getIdentifier(final Optional<TypeDeclaration> node) { return getIdentifier(node.orNull()); }
From source file:com.arpnetworking.configuration.jackson.BaseJsonNodeSource.java
/** * Find the <code>JsonNode</code> if one exists from a specified root node * given a sequence of keys to look-up./*from w w w . j a va 2s . c o m*/ * * @param node The root <code>JsonNode</code>. * @param keys The sequence of keys to search for. * @return The <code>Optional</code> <code>JsonNode</code> instance. */ protected static Optional<JsonNode> getValue(final Optional<JsonNode> node, final String... keys) { JsonNode jsonNode = node.orNull(); for (final String key : keys) { if (jsonNode == null) { break; } jsonNode = jsonNode.get(key); } return Optional.fromNullable(jsonNode); }
From source file:com.on_site.frizzle.debug.LoggingMixin.java
static <T> T instrument(Class<T> typeKey, String name, Optional<T> value) { T thing = value.orNull(); if (thing instanceof Function) { return typeKey.cast(new LoggingFunction(name, (Function) thing)); }/*from ww w .j a va 2 s. c o m*/ return thing; }
From source file:com.jythonui.server.RUtils.java
public static void retrieveCreateModif(RMap dest, Object sou) { Optional<Date> d = retrieveD(sou, ISharedConsts.CREATIONDATEPROPERTY); if (d != null) dest.setCreationDate(d.orNull()); d = retrieveD(sou, ISharedConsts.MODIFDATEPROPERTY); if (d != null) dest.setModifDate(d.orNull());// ww w . j a va2 s .c o m Optional<String> s = retrieveS(sou, ISharedConsts.CREATIONPERSONPROPERTY); if (s != null) dest.setCreationPerson(s.orNull()); s = retrieveS(sou, ISharedConsts.MODIFPERSONPROPERTY); if (s != null) dest.setModifPerson(s.orNull()); }
From source file:com.palantir.atlasdb.http.AtlasDbHttpClients.java
/** * Returns a feign {@link Client} wrapping a {@link com.squareup.okhttp.OkHttpClient} client with optionally * specified {@link SSLSocketFactory}.//from w w w .j a v a2 s . c o m */ private static Client newOkHttpClient(Optional<SSLSocketFactory> sslSocketFactory) { com.squareup.okhttp.OkHttpClient client = new com.squareup.okhttp.OkHttpClient(); client.setSslSocketFactory(sslSocketFactory.orNull()); return new OkHttpClient(client); }
From source file:org.apache.aurora.scheduler.thrift.Fixtures.java
static Response response(ResponseCode code, Optional<Result> result, String... messages) { Response response = Responses.empty().setResponseCode(code).setResult(result.orNull()); if (messages.length > 0) { response.setDetails(FluentIterable.from(Arrays.asList(messages)).transform(MESSAGE_TO_DETAIL).toList()); }/*from w w w . j a v a2s.c o m*/ return response; }
From source file:org.locationtech.geogig.model.FieldType.java
/** * @return the {@code FieldType} corresponding to the {@link Optional}'s value. * @see #forValue(Object)/* w w w . j av a2s. com*/ */ public static FieldType forValue(Optional<Object> field) { return forValue(field.orNull()); }