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 not FAILED.
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:
  1. CREATED: the service was created successfully, the service info is available via serviceInfo().
  2. 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 CloudServiceDeferredStateEvent to catch updates of the retries.
  3. FAILED: indicates that the service couldn't be created.
Since:
4.0
  • Field Details

  • Constructor Details

  • Method Details

    • deferred

      @NonNull public static @NonNull ServiceCreateResult deferred(@NonNull @NonNull UUID creationId)
      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

      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

      @NonNull public @NonNull UUID 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 is FAILED.
    • serviceInfo

      @NonNull public @NonNull ServiceInfoSnapshot serviceInfo()
      Get the service info of the service which was created. This is only present if the state of this result is CREATED.
      Returns:
      the service info of the created service.
      Throws:
      IllegalStateException - if called when the state of this result is not CREATED.
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • state

      Returns the value of the state record component.
      Returns:
      the value of the state record component