/** * Builds a new instance of the primitive. * <p> * The returned instance will be distinct from all other instances of the same primitive on this node, with a * distinct session, ordering guarantees, memory, etc. * * @return a new instance of the primitive */ @Override public P build() { try { return buildAsync().join(); } catch (Exception e) { if (e instanceof CompletionException && e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw e; } } }
@Override @SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>, P extends SyncPrimitive> CompletableFuture<P> getPrimitiveAsync( String name, PrimitiveType<?, C, P> primitiveType, C primitiveConfig) { return cache.getPrimitive(name, () -> { C config = primitiveConfig; if (config == null) { config = configService.getConfig(name, primitiveType); } return primitiveType.newBuilder(name, config, managementService).buildAsync(); }); }
@Override @SuppressWarnings("unchecked") public <C extends PrimitiveConfig<C>, P extends SyncPrimitive> CompletableFuture<P> getPrimitiveAsync( String name, PrimitiveType<?, C, P> primitiveType, C primitiveConfig) { return cache.getPrimitive(name, () -> { C config = primitiveConfig; if (config == null) { config = configService.getConfig(name, primitiveType); } return primitiveType.newBuilder(name, config, managementService).buildAsync(); }); }