Class ServiceCreateResult
java.lang.Object
eu.cloudnetservice.driver.service.ServiceCreateResult
Represents the result of a service creation. A result can have three states:
- CREATED: the service was created successfully, the service info is available via
serviceInfo(). - DEFERRED: this state can only happen when a retry configuration was specified during the creation of the
service. In that case, the creation id of the result can be used to listen to
the
CloudServiceDeferredStateEventto catch updates of the retries. - FAILED: indicates that the service couldn't be created.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents the state of a service creation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final UUIDstatic final ServiceCreateResultA static create result indicating that the service creation failed.private final ServiceInfoSnapshotprivate final ServiceCreateResult.State -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateServiceCreateResult(@NonNull ServiceCreateResult.State state, @Nullable UUID creationId, @Nullable ServiceInfoSnapshot serviceInfo) Creates a new result instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull ServiceCreateResultcreated(@NonNull ServiceInfoSnapshot serviceInfo) Creates a new result with the state set to created and using the given service info.Get the creation id of this create result.static @NonNull ServiceCreateResultCreates a new result with the state set to deferred and using the given creation id.Get the service info of the service which was created.state()Get the state of this service creation.
-
Field Details
-
FAILED
A static create result indicating that the service creation failed. -
state
-
creationId
-
serviceInfo
-
-
Constructor Details
-
ServiceCreateResult
private ServiceCreateResult(@NonNull @NonNull ServiceCreateResult.State state, @Nullable @Nullable UUID creationId, @Nullable @Nullable ServiceInfoSnapshot serviceInfo) Creates a new result instance.- Parameters:
state- the creation state of the service.creationId- the creation id of this result, if the state is notFAILED.serviceInfo- the underlying service info, if the service was created successfully.- Throws:
NullPointerException- if the given state is null.IllegalArgumentException- if the creation id is missing or the service info depending on the given state.
-
-
Method Details
-
deferred
Creates a new result with the state set to deferred and using the given creation id.- Parameters:
creationId- the creation id for deferred service event updates.- Returns:
- a new result instance.
- Throws:
NullPointerException- if the given creation id is null.
-
created
@NonNull public static @NonNull ServiceCreateResult created(@NonNull @NonNull ServiceInfoSnapshot serviceInfo) Creates a new result with the state set to created and using the given service info.- Parameters:
serviceInfo- the service info of the created service.- Returns:
- a new result instance.
- Throws:
NullPointerException- if the given service info is null.
-
creationId
Get the creation id of this create result. If the service was created successfully, this id is set to the unique id of the service. If the creation was deferred the id is set to a unique notification id which can be used to identify the final creation result.- Returns:
- the creation id of this service.
- Throws:
IllegalStateException- if called when the state of this result isFAILED.
-
serviceInfo
Get the service info of the service which was created. This is only present if the state of this result isCREATED.- Returns:
- the service info of the created service.
- Throws:
IllegalStateException- if called when the state of this result is notCREATED.
-
state
Get the state of this service creation. Use this to ensure that the service creation was successful when accessingcreationId()orserviceInfo().- Returns:
- the state of this service creation.
-