Package io.atomix.primitive
Class PrimitiveBuilder<B extends PrimitiveBuilder<B,C,P>,C extends PrimitiveConfig,P extends SyncPrimitive>
java.lang.Object
io.atomix.primitive.PrimitiveBuilder<B,C,P>
- Type Parameters:
B- builder typeP- primitive type
- All Implemented Interfaces:
io.atomix.utils.Builder<P>
public abstract class PrimitiveBuilder<B extends PrimitiveBuilder<B,C,P>,C extends PrimitiveConfig,P extends SyncPrimitive> extends Object implements io.atomix.utils.Builder<P>
Abstract builder for distributed primitives.
-
Constructor Summary
Constructors Constructor Description PrimitiveBuilder(PrimitiveType type, String name, C config, PrimitiveManagementService managementService) -
Method Summary
Modifier and Type Method Description Pbuild()Builds a new instance of the primitive.abstract CompletableFuture<P>buildAsync()Builds a new instance of the primitive asynchronously.Pget()Gets or builds a singleton instance of the primitive.CompletableFuture<P>getAsync()Gets or builds a singleton instance of the primitive asynchronously.BwithReadOnly()Sets the primitive to read-only.BwithReadOnly(boolean readOnly)Sets whether the primitive is read-only.BwithSerializer(io.atomix.utils.serializer.Serializer serializer)Sets the primitive serializer.
-
Constructor Details
-
PrimitiveBuilder
public PrimitiveBuilder(PrimitiveType type, String name, C config, PrimitiveManagementService managementService)
-
-
Method Details
-
withSerializer
Sets the primitive serializer.- Parameters:
serializer- the primitive serializer- Returns:
- the primitive builder
-
withReadOnly
Sets the primitive to read-only.- Returns:
- the primitive builder
-
withReadOnly
Sets whether the primitive is read-only.- Parameters:
readOnly- whether the primitive is read-only- Returns:
- the primitive builder
-
build
Builds a new instance of the primitive.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.
- Specified by:
buildin interfaceio.atomix.utils.Builder<B extends PrimitiveBuilder<B,C,P>>- Returns:
- a new instance of the primitive
-
buildAsync
Builds a new instance of the primitive asynchronously.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.
- Returns:
- asynchronous distributed primitive
-
get
Gets or builds a singleton instance of the primitive.The returned primitive will be shared by all
get()calls for the named primitive. If no instance has yet been constructed, the instance will be built from this builder's configuration.- Returns:
- a singleton instance of the primitive
-
getAsync
Gets or builds a singleton instance of the primitive asynchronously.The returned primitive will be shared by all
get()calls for the named primitive. If no instance has yet been constructed, the instance will be built from this builder's configuration.- Returns:
- a singleton instance of the primitive
-