本文整理了Java中com.apollographql.apollo.api.internal.Utils.checkNotNull()
方法的一些代码示例,展示了Utils.checkNotNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.checkNotNull()
方法的具体详情如下:
包路径:com.apollographql.apollo.api.internal.Utils
类名称:Utils
方法名:checkNotNull
[英]Checks if the object is null. Returns the object if it is not null, else throws a NullPointerException.
[中]检查对象是否为空。如果对象不为null,则返回该对象,否则抛出NullPointerException。
代码示例来源:origin: apollographql/apollo-android
/**
* @param evictionPolicy {@link EvictionPolicy} to manage the primary cache.
*/
public LruNormalizedCacheFactory(EvictionPolicy evictionPolicy) {
this.evictionPolicy = checkNotNull(evictionPolicy, "evictionPolicy == null");
}
代码示例来源:origin: apollographql/apollo-android
/**
* <p>Set the API server's base url.</p>
*
* @param serverUrl the url to set.
* @return The {@link Builder} object to be used for chaining method calls
*/
public Builder serverUrl(@NotNull HttpUrl serverUrl) {
this.serverUrl = checkNotNull(serverUrl, "serverUrl is null");
return this;
}
代码示例来源:origin: apollographql/apollo-android
/**
* Sets the http cache policy to be used as default for all GraphQL {@link Query} operations. Will be ignored for
* any {@link Mutation} operations. By default http cache policy is set to {@link HttpCachePolicy#NETWORK_ONLY}.
*
* @return The {@link Builder} object to be used for chaining method calls
*/
public Builder defaultHttpCachePolicy(@NotNull HttpCachePolicy.Policy cachePolicy) {
this.defaultHttpCachePolicy = checkNotNull(cachePolicy, "cachePolicy == null");
return this;
}
代码示例来源:origin: apollographql/apollo-android
@Override
public String apply(Object o) {
checkNotNull(o); // eager for GWT.
return o.toString();
}
代码示例来源:origin: apollographql/apollo-android
@Override
public <T> void subscribe(@NotNull final Subscription<?, T, ?> subscription,
@NotNull final SubscriptionManager.Callback<T> callback) {
checkNotNull(subscription, "subscription == null");
checkNotNull(callback, "callback == null");
dispatcher.execute(new Runnable() {
@Override
public void run() {
doSubscribe(subscription, callback);
}
});
}
代码示例来源:origin: apollographql/apollo-android
@Override public <V> Optional<V> flatMap(Function<? super T, Optional<V>> function) {
checkNotNull(function);
return checkNotNull(function.apply(reference),
"the Function passed to Optional.flatMap() must not return null.");
}
代码示例来源:origin: apollographql/apollo-android
@Override
public void unsubscribe(@NotNull final Subscription subscription) {
checkNotNull(subscription, "subscription == null");
dispatcher.execute(new Runnable() {
@Override
public void run() {
doUnsubscribe(subscription);
}
});
}
代码示例来源:origin: apollographql/apollo-android
private <CALL> Set<CALL> activeCalls(Map<OperationName, Set<CALL>> registry, @NotNull OperationName operationName) {
checkNotNull(operationName, "operationName == null");
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (registry) {
Set<CALL> calls = registry.get(operationName);
return calls != null ? new HashSet<>(calls) : Collections.<CALL>emptySet();
}
}
代码示例来源:origin: apollographql/apollo-android
Response(Builder<T> builder) {
operation = checkNotNull(builder.operation, "operation == null");
data = builder.data;
errors = builder.errors != null ? unmodifiableList(builder.errors) : Collections.<Error>emptyList();
dependentKeys = builder.dependentKeys != null ? unmodifiableSet(builder.dependentKeys)
: Collections.<String>emptySet();
fromCache = builder.fromCache;
}
代码示例来源:origin: apollographql/apollo-android
@Override
public <V> Optional<V> transform(Function<? super T, V> function) {
checkNotNull(function);
return Optional.absent();
}
代码示例来源:origin: apollographql/apollo-android
/**
* Create new cache policy with expire after timeout configuration. Cached response is treated as expired if it's
* served date exceeds.
*
* @param expireTimeout expire timeout after which cached response is treated as expired
* @param expireTimeUnit time unit
* @return new cache policy
*/
public ExpirePolicy expireAfter(long expireTimeout, @NotNull TimeUnit expireTimeUnit) {
return new ExpirePolicy(fetchStrategy, expireTimeout, checkNotNull(expireTimeUnit), expireAfterRead);
}
代码示例来源:origin: apollographql/apollo-android
@NotNull @Override public ApolloMutationCall<T> refetchQueries(@NotNull Query... queries) {
if (state.get() != IDLE) throw new IllegalStateException("Already Executed");
return toBuilder()
.refetchQueries(Arrays.asList(checkNotNull(queries, "queries == null")))
.build();
}
代码示例来源:origin: apollographql/apollo-android
@NotNull @Override public RealApolloCall<T> httpCachePolicy(@NotNull HttpCachePolicy.Policy httpCachePolicy) {
if (state.get() != IDLE) throw new IllegalStateException("Already Executed");
return toBuilder()
.httpCachePolicy(checkNotNull(httpCachePolicy, "httpCachePolicy == null"))
.build();
}
代码示例来源:origin: apollographql/apollo-android
@NotNull @Override public RealApolloCall<T> responseFetcher(@NotNull ResponseFetcher fetcher) {
if (state.get() != IDLE) throw new IllegalStateException("Already Executed");
return toBuilder()
.responseFetcher(checkNotNull(fetcher, "responseFetcher == null"))
.build();
}
代码示例来源:origin: apollographql/apollo-android
public final NormalizedCacheFactory<T> chain(@NotNull NormalizedCacheFactory factory) {
checkNotNull(factory, "factory == null");
NormalizedCacheFactory leafFactory = this;
while (leafFactory.nextFactory.isPresent()) {
leafFactory = (NormalizedCacheFactory) leafFactory.nextFactory.get();
}
leafFactory.nextFactory = Optional.of(factory);
return this;
}
}
代码示例来源:origin: apollographql/apollo-android
/**
* <p>Adds provided {@link ApolloMutationCall} that is currently in progress.</p>
*
* <p><b>Note</b>: This method needs to be called right before an apolloCall is executed.</p>
*/
void registerMutationCall(@NotNull ApolloMutationCall apolloMutationCall) {
checkNotNull(apolloMutationCall, "apolloMutationCall == null");
OperationName operationName = apolloMutationCall.operation().name();
registerCall(activeMutationCalls, operationName, apolloMutationCall);
}
代码示例来源:origin: apollographql/apollo-android
public static String toJsonString(@NotNull Object data) throws IOException {
checkNotNull(data, "data == null");
Buffer buffer = new Buffer();
JsonWriter jsonWriter = JsonWriter.of(buffer);
writeToJson(data, jsonWriter);
jsonWriter.close();
return buffer.readUtf8();
}
代码示例来源:origin: apollographql/apollo-android
@Override public void writeNumber(@NotNull String fieldName, Number value) throws IOException {
checkNotNull(fieldName, "fieldName == null");
if (value != null) {
jsonWriter.name(fieldName).value(value);
} else {
jsonWriter.name(fieldName).nullValue();
}
}
代码示例来源:origin: apollographql/apollo-android
@Override public void writeMap(@NotNull String fieldName, Map<String, Object> value) throws IOException {
checkNotNull(fieldName, "fieldName == null");
if (value == null) {
jsonWriter.name(fieldName).nullValue();
} else {
jsonWriter.name(fieldName);
writeToJson(value, jsonWriter);
}
}
代码示例来源:origin: apollographql/apollo-android
@NotNull public Set<String> mergeOptimisticUpdate(@NotNull final Record record) {
checkNotNull(record, "record == null");
final RecordJournal journal = lruCache.getIfPresent(record.key());
if (journal == null) {
lruCache.put(record.key(), new RecordJournal(record));
return Collections.singleton(record.key());
} else {
return journal.commit(record);
}
}
内容来源于网络,如有侵权,请联系作者删除!