Record Class ServiceCreateResult
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.service.ServiceCreateResult
- Record Components:
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.
public record ServiceCreateResult(@NonNull ServiceCreateResult.State state, @Nullable UUID creationId, @Nullable ServiceInfoSnapshot serviceInfo)
extends Record
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 TypeFieldDescriptionThe field for thecreationIdrecord component.static final ServiceCreateResultA static create result indicating that the service creation failed.private final @Nullable ServiceInfoSnapshotThe field for theserviceInforecord component.private final @NonNull ServiceCreateResult.StateThe field for thestaterecord component. -
Constructor Summary
ConstructorsConstructorDescriptionServiceCreateResult(@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.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Get the service info of the service which was created.state()Returns the value of thestaterecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
state
The field for thestaterecord component. -
creationId
The field for thecreationIdrecord component. -
serviceInfo
The field for theserviceInforecord component. -
FAILED
A static create result indicating that the service creation failed.
-
-
Constructor Details
-
ServiceCreateResult
public 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.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
state
Returns the value of thestaterecord component.- Returns:
- the value of the
staterecord component
-