Java Code Examples for java.util.concurrent.CompletableFuture#completedFuture()
The following examples show how to use
java.util.concurrent.CompletableFuture#completedFuture() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TeiidDdlTextDocumentService.java From syndesis with Apache License 2.0 | 6 votes |
@Override public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion( CompletionParams completionParams) { String uri = completionParams.getTextDocument().getUri(); LOGGER.debug("completion: {}", uri); TextDocumentItem doc = openedDocuments.get(uri); // get applicable completion items List<CompletionItem> items = completionProvider.getCompletionItems(doc.getText(), completionParams.getPosition()); // if items exist, return them if (items != null && !items.isEmpty()) { return CompletableFuture.completedFuture(Either.forLeft(items)); } // if items do no exist return empty results return CompletableFuture.completedFuture(Either.forLeft(Collections.emptyList())); }
Example 2
Source File: VirtualChestActions.java From VirtualChest with GNU Lesser General Public License v3.0 | 5 votes |
private CompletableFuture<CommandResult> processTellraw(CommandResult parent, String command, ClassToInstanceMap<Context> contextMap) { Text text = TextSerializers.JSON.deserialize(command); contextMap.getInstance(Context.PLAYER).getPlayer().ifPresent(p -> p.sendMessage(text)); return CompletableFuture.completedFuture(CommandResult.success()); }
Example 3
Source File: InspectorService.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
public CompletableFuture<ArrayList<DiagnosticsNode>> getBoundingBoxes(DiagnosticsNode root, DiagnosticsNode target) { final JsonObject params = new JsonObject(); if (root == null || target == null || root.getValueRef() == null || target.getValueRef() == null) { return CompletableFuture.completedFuture(new ArrayList<>()); } params.addProperty("rootId", root.getValueRef().getId()); params.addProperty("targetId", target.getValueRef().getId()); params.addProperty("groupName", groupName); return parseDiagnosticsNodesDaemon( inspectorLibrary.invokeServiceMethod("ext.flutter.inspector.getBoundingBoxes", params).thenApplyAsync((o) -> { if (o == null) return null; return o.get("result"); }), null); }
Example 4
Source File: VerifyDistributedTracingConfigBehaviorAndTagsComponentTest.java From riposte with Apache License 2.0 | 5 votes |
@Override public @NotNull CompletableFuture<ResponseInfo<String>> execute( @NotNull RequestInfo<Void> request, @NotNull Executor longRunningTaskExecutor, @NotNull ChannelHandlerContext ctx ) { if ("true".equals(request.getHeaders().get(TRIGGER_DOWNSTREAM_ERROR_HEADER_KEY))) { throw new RuntimeException("intentional downstream exception"); } return CompletableFuture.completedFuture( ResponseInfo.newBuilder(RESPONSE_PAYLOAD).build() ); }
Example 5
Source File: VerifyPayloadHandlingComponentTest.java From riposte with Apache License 2.0 | 5 votes |
@Override public @NotNull CompletableFuture<ResponseInfo<String>> execute( @NotNull RequestInfo<Void> request, @NotNull Executor longRunningTaskExecutor, @NotNull ChannelHandlerContext ctx ) { if (request.getContent() != null) throw new IllegalStateException("Since the deserialized type is Void, getContent() should return null. Instead it returned: " + request.getContent()); verifyIncomingPayloadByteHash(request, false); return CompletableFuture.completedFuture(ResponseInfo.newBuilder("success_void").build()); }
Example 6
Source File: CachingSignalEnrichmentFacade.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Override public CompletionStage<JsonObject> retrievePartialThing(final ThingId thingId, final JsonFieldSelector jsonFieldSelector, final DittoHeaders dittoHeaders, @Nullable final Signal<?> concernedSignal) { if (concernedSignal instanceof ThingDeleted && !(ProtocolAdapter.isLiveSignal(concernedSignal))) { // twin deleted events should not be enriched, return empty JsonObject return CompletableFuture.completedFuture(JsonObject.empty()); } // as second step only return what was originally requested as fields: return doRetrievePartialThing(thingId, jsonFieldSelector, dittoHeaders, concernedSignal) .thenApply(jsonObject -> jsonObject.get(jsonFieldSelector)); }
Example 7
Source File: ServerChannelUpdaterDelegateImpl.java From Javacord with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Void> update() { ObjectNode body = JsonNodeFactory.instance.objectNode(); if (prepareUpdateBody(body)) { return new RestRequest<Void>(channel.getApi(), RestMethod.PATCH, RestEndpoint.CHANNEL) .setUrlParameters(channel.getIdAsString()) .setBody(body) .setAuditLogReason(reason) .execute(result -> null); } else { return CompletableFuture.completedFuture(null); } }
Example 8
Source File: OptionParamValueURIInstance.java From camel-language-server with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<List<CompletionItem>> getCompletions(CompletableFuture<CamelCatalog> camelCatalog, int positionInCamelUri, TextDocumentItem docItem) { if(getStartPositionInUri() <= positionInCamelUri && positionInCamelUri <= getEndPositionInUri()) { return camelCatalog.thenApply(new CamelOptionValuesCompletionsFuture(this, getFilter(positionInCamelUri))); } else { return CompletableFuture.completedFuture(Collections.emptyList()); } }
Example 9
Source File: InMemoryBucketManager.java From pravega with Apache License 2.0 | 4 votes |
@Override CompletableFuture<Boolean> takeBucketOwnership(int bucket, String processId, Executor executor) { Preconditions.checkArgument(bucket < getBucketCount()); return CompletableFuture.completedFuture(true); }
Example 10
Source File: TestJobClient.java From flink with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<JobExecutionResult> getJobExecutionResult(ClassLoader userClassloader) { return CompletableFuture.completedFuture(jobExecutionResult); }
Example 11
Source File: RequestProcessorTest.java From pravega with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<Void> writeBack(TestEvent1 event) { queue.add(event); return CompletableFuture.completedFuture(null); }
Example 12
Source File: MockRpcClient.java From waltz with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<Boolean> removePreferredPartition(Endpoint serverEndpoint, int partitionId) throws InterruptedException { return CompletableFuture.completedFuture(true); }
Example 13
Source File: BeanWithPayloadProcessors.java From smallrye-reactive-messaging with Apache License 2.0 | 4 votes |
@Incoming("sink-" + DEFAULT_ACKNOWLEDGMENT_BUILDER) @Acknowledgment(Acknowledgment.Strategy.NONE) public CompletionStage<Void> sinkDefBuilder(Message<String> ignored) { return CompletableFuture.completedFuture(null); }
Example 14
Source File: LSPClient.java From MSPaintIDE with MIT License | 4 votes |
@Override public CompletableFuture<List<WorkspaceFolder>> workspaceFolders() { return CompletableFuture.completedFuture(Collections.emptyList()); }
Example 15
Source File: AsyncDistributedJavaCollection.java From atomix with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<Boolean> containsAll(Collection<? extends E> c) { return CompletableFuture.completedFuture(collection.containsAll(c)); }
Example 16
Source File: AbstractHandler.java From flink with Apache License 2.0 | 4 votes |
protected CompletableFuture<Void> closeHandlerAsync() { return CompletableFuture.completedFuture(null); }
Example 17
Source File: MemoryStorageManager.java From bullet-core with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<byte[]> get(String id) { return CompletableFuture.completedFuture(storage.get(id)); }
Example 18
Source File: NoopRpcAuthorizer.java From vespa with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<Void> authorizeFileRequest(Request request) { return CompletableFuture.completedFuture(null); }
Example 19
Source File: DoNothingConnectionRegistry.java From hbase with Apache License 2.0 | 4 votes |
@Override public CompletableFuture<RegionLocations> getMetaRegionLocations() { return CompletableFuture.completedFuture(null); }
Example 20
Source File: StreamTransactionMetadataTasks.java From pravega with Apache License 2.0 | 3 votes |
/** * Ping a txn thereby updating its timeout to current time + lease. * * Post-condition: * 1. If ping request completes successfully, then * (a) txn timeout is set to lease + current time in timeout service, * (b) txn version in timeout service equals version of txn node in store, * (c) if txn's timeout was not previously tracked in timeout service of current process, * then version of txn node in store is updated, thus fencing out other processes tracking timeout for this txn, * (d) txn is present in the host-txn index of current host, * * 2. If process fails before responding to the client, then since txn is present in the host-txn index, * some other controller process shall abort the txn after maxLeaseValue * * Store read/update operation is not invoked on receiving ping request for a txn that is being tracked in the * timeout service. Otherwise, if the txn is not being tracked in the timeout service, txn node is read from * the store and updated. * * @param scope scope name. * @param stream stream name. * @param txnId txn id. * @param lease txn lease. * @param ctx context. * @return ping status. */ CompletableFuture<PingTxnStatus> pingTxnBody(final String scope, final String stream, final UUID txnId, final long lease, final OperationContext ctx) { if (!timeoutService.isRunning()) { return CompletableFuture.completedFuture(createStatus(Status.DISCONNECTED)); } log.debug("Txn={}, updating txn node in store and extending lease", txnId); return fenceTxnUpdateLease(scope, stream, txnId, lease, ctx); }