com.apollographql.apollo.api.internal.Optional.apply()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中com.apollographql.apollo.api.internal.Optional.apply()方法的一些代码示例,展示了Optional.apply()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Optional.apply()方法的具体详情如下:
包路径:com.apollographql.apollo.api.internal.Optional
类名称:Optional
方法名:apply

Optional.apply介绍

暂无

代码示例

代码示例来源:origin: apollographql/apollo-android

@SuppressWarnings("ResultOfMethodCallIgnored")
 @Override public void onFetch(final ApolloInterceptor.FetchSourceType sourceType) {
  responseCallback().apply(new Action<Callback<T>>() {
   @Override public void apply(@NotNull Callback<T> callback) {
    switch (sourceType) {
     case CACHE:
      callback.onStatusEvent(StatusEvent.FETCH_CACHE);
      break;
     case NETWORK:
      callback.onStatusEvent(StatusEvent.FETCH_NETWORK);
      break;
     default:
      break;
    }
   }
  });
 }
};

代码示例来源:origin: apollographql/apollo-android

@SuppressWarnings("ResultOfMethodCallIgnored")
@Override public void clearAll() {
 lruCache.invalidateAll();
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@NotNull NormalizedCache cache) {
   cache.clearAll();
  }
 });
}

代码示例来源:origin: apollographql/apollo-android

@SuppressWarnings("ResultOfMethodCallIgnored")
@Override public void clearAll() {
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@NotNull NormalizedCache cache) {
   cache.clearAll();
  }
 });
 clearCurrentCache();
}

代码示例来源:origin: apollographql/apollo-android

@SuppressWarnings("ResultOfMethodCallIgnored")
private synchronized void activate(Optional<Callback<T>> callback) {
 switch (state.get()) {
  case IDLE:
   originalCallback.set(callback.orNull());
   tracker.registerCall(this);
   callback.apply(new Action<Callback<T>>() {
    @Override public void apply(@NotNull Callback<T> callback) {
     callback.onStatusEvent(StatusEvent.SCHEDULED);
    }
   });
   break;
  case CANCELED:
   throw new ApolloCanceledException("Call is cancelled.");
  case TERMINATED:
  case ACTIVE:
   throw new IllegalStateException("Already Executed");
  default:
   throw new IllegalStateException("Unknown state");
 }
 state.set(ACTIVE);
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Override public void onFetch(final ApolloInterceptor.FetchSourceType sourceType) {
  responseCallback().apply(new Action<Callback<T>>() {
   @Override public void apply(@Nonnull Callback<T> callback) {
    switch (sourceType) {
     case CACHE:
      callback.onStatusEvent(StatusEvent.FETCH_CACHE);
      break;
     case NETWORK:
      callback.onStatusEvent(StatusEvent.FETCH_NETWORK);
      break;
     default:
      break;
    }
   }
  });
 }
};

代码示例来源:origin: com.amazonaws/aws-android-sdk-appsync-runtime

@Override public void onFetch(final ApolloInterceptor.FetchSourceType sourceType) {
  responseCallback().apply(new Action<Callback<T>>() {
   @Override public void apply(@Nonnull Callback<T> callback) {
    switch (sourceType) {
     case CACHE:
      callback.onStatusEvent(StatusEvent.FETCH_CACHE);
      break;
     case NETWORK:
      callback.onStatusEvent(StatusEvent.FETCH_NETWORK);
      break;
     default:
      break;
    }
   }
  });
 }
};

代码示例来源:origin: com.amazonaws/aws-android-sdk-appsync-runtime

@Override public void clearAll() {
 lruCache.invalidateAll();
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.clearAll();
  }
 });
}

代码示例来源:origin: com.amazonaws/aws-android-sdk-appsync-runtime

@Override public void clearAll() {
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.clearAll();
  }
 });
 clearCurrentCache();
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Override public void clearAll() {
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.clearAll();
  }
 });
 clearCurrentCache();
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Override public void clearAll() {
 lruCache.invalidateAll();
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.clearAll();
  }
 });
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Override
public void clearAll() {
 //noinspection ResultOfMethodCallIgnored
 Optional<NormalizedCache> normalizedCacheOptional = nextCache().apply(new Action<NormalizedCache>() {
  @Override
  public void apply(@Nonnull NormalizedCache cache) {
   cache.clearAll();
  }
 });
 clearCurrentCache();
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Nonnull @Override
public Set<String> merge(@Nonnull final Collection<Record> recordSet,
             @Nonnull final CacheHeaders cacheHeaders) {
 if (cacheHeaders.hasHeader(DO_NOT_STORE)) {
  return Collections.emptySet();
 }
 //noinspection ResultOfMethodCallIgnored
 Optional<NormalizedCache> normalizedCacheOptional = nextCache().apply(new Action<NormalizedCache>() {
  @Override
  public void apply(@Nonnull NormalizedCache cache) {
   for (Record record : recordSet) {
    cache.merge(record, cacheHeaders);
   }
  }
 });
 Set<String> changedKeys;
 try {
  database.beginTransaction();
  changedKeys = super.merge(recordSet, cacheHeaders);
  database.setTransactionSuccessful();
 } finally {
  database.endTransaction();
 }
 return changedKeys;
}

代码示例来源:origin: com.amazonaws/aws-android-sdk-appsync-runtime

private synchronized void activate(Optional<Callback<T>> callback) throws ApolloCanceledException {
 switch (state.get()) {
  case IDLE:
   originalCallback.set(callback.orNull());
   tracker.registerCall(this);
   callback.apply(new Action<Callback<T>>() {
    @Override public void apply(@Nonnull Callback<T> callback) {
     callback.onStatusEvent(StatusEvent.SCHEDULED);
    }
   });
   break;
  case CANCELED:
   throw new ApolloCanceledException("Call is cancelled.");
  case TERMINATED:
  case ACTIVE:
   throw new IllegalStateException("Already Executed");
  default:
   throw new IllegalStateException("Unknown state");
 }
 state.set(ACTIVE);
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

private synchronized void activate(Optional<Callback<T>> callback) throws ApolloCanceledException {
 switch (state.get()) {
  case IDLE:
   originalCallback.set(callback.orNull());
   tracker.registerCall(this);
   callback.apply(new Action<Callback<T>>() {
    @Override public void apply(@Nonnull Callback<T> callback) {
     callback.onStatusEvent(StatusEvent.SCHEDULED);
    }
   });
   break;
  case CANCELED:
   throw new ApolloCanceledException("Call is cancelled.");
  case TERMINATED:
  case ACTIVE:
   throw new IllegalStateException("Already Executed");
  default:
   throw new IllegalStateException("Unknown state");
 }
 state.set(ACTIVE);
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Nullable public Record loadRecord(@Nonnull final String key, @Nonnull final CacheHeaders cacheHeaders) {
 return selectRecordForKey(key)
   .apply(new Action<Record>() {
    @Override
    public void apply(@Nonnull Record record) {
     if (cacheHeaders.hasHeader(EVICT_AFTER_READ)) {
      deleteRecord(key);
     }
    }
   })
   .or(nextCache().flatMap(new Function<NormalizedCache, Optional<Record>>() {
    @Nonnull @Override
    public Optional<Record> apply(@Nonnull NormalizedCache cache) {
     return Optional.fromNullable(cache.loadRecord(key, cacheHeaders));
    }
   }))
   .orNull();
}

代码示例来源:origin: com.amazonaws/aws-android-sdk-appsync-runtime

@Nonnull @Override
public Set<String> merge(@Nonnull final Record apolloRecord, @Nonnull final CacheHeaders cacheHeaders) {
 if (cacheHeaders.hasHeader(GraphQLCacheHeaders.DO_NOT_STORE)) {
  return Collections.emptySet();
 }
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.merge(apolloRecord, cacheHeaders);
  }
 });
 final Record oldRecord = lruCache.getIfPresent(apolloRecord.key());
 if (oldRecord == null) {
  lruCache.put(apolloRecord.key(), apolloRecord);
  return Collections.emptySet();
 } else {
  Set<String> changedKeys = oldRecord.mergeWith(apolloRecord);
  //re-insert to trigger new weight calculation
  lruCache.put(apolloRecord.key(), oldRecord);
  return changedKeys;
 }
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Nonnull @Override
public Set<String> merge(@Nonnull final Record apolloRecord, @Nonnull final CacheHeaders cacheHeaders) {
 if (cacheHeaders.hasHeader(GraphQLCacheHeaders.DO_NOT_STORE)) {
  return Collections.emptySet();
 }
 //noinspection ResultOfMethodCallIgnored
 nextCache().apply(new Action<NormalizedCache>() {
  @Override public void apply(@Nonnull NormalizedCache cache) {
   cache.merge(apolloRecord, cacheHeaders);
  }
 });
 final Record oldRecord = lruCache.getIfPresent(apolloRecord.key());
 if (oldRecord == null) {
  lruCache.put(apolloRecord.key(), apolloRecord);
  return Collections.emptySet();
 } else {
  Set<String> changedKeys = oldRecord.mergeWith(apolloRecord);
  //re-insert to trigger new weight calculation
  lruCache.put(apolloRecord.key(), oldRecord);
  return changedKeys;
 }
}

代码示例来源:origin: awslabs/aws-mobile-appsync-sdk-android

@Nonnull public Set<String> merge(@Nonnull final Record apolloRecord, @Nonnull final CacheHeaders cacheHeaders) {
 if (cacheHeaders.hasHeader(DO_NOT_STORE)) {
  return Collections.emptySet();
 }
 //noinspection ResultOfMethodCallIgnored
 Optional<NormalizedCache> normalizedCacheOptional = nextCache().apply(new Action<NormalizedCache>() {
  @Override
  public void apply(@Nonnull NormalizedCache cache) {
   cache.merge(apolloRecord, cacheHeaders);
  }
 });
 Optional<Record> optionalOldRecord = selectRecordForKey(apolloRecord.key());
 Set<String> changedKeys;
 if (!optionalOldRecord.isPresent()) {
  createRecord(apolloRecord.key(), recordFieldAdapter.toJson(apolloRecord.fields()));
  changedKeys = Collections.emptySet();
 } else {
  Record oldRecord = optionalOldRecord.get();
  changedKeys = oldRecord.mergeWith(apolloRecord);
  if (!changedKeys.isEmpty()) {
   updateRecord(oldRecord.key(), recordFieldAdapter.toJson(oldRecord.fields()));
  }
 }
 return changedKeys;
}

相关文章