Class ImmutableQueryResults.Builder

java.lang.Object
org.kiwiproject.consul.model.query.ImmutableQueryResults.Builder
Enclosing class:
ImmutableQueryResults

public static final class ImmutableQueryResults.Builder extends Object
Builds instances of type ImmutableQueryResults. Initialize attributes and then invoke the build() method to create an immutable instance.

Builder is not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.

  • Method Details

    • from

      @CanIgnoreReturnValue public final ImmutableQueryResults.Builder from(QueryResults instance)
      Fill a builder with attribute values from the provided QueryResults instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.
      Parameters:
      instance - The instance from which to copy values
      Returns:
      this builder for use in a chained invocation
    • service

      @CanIgnoreReturnValue public final ImmutableQueryResults.Builder service(String service)
      Initializes the value for the service attribute.
      Parameters:
      service - The value for service
      Returns:
      this builder for use in a chained invocation
    • addNodes

      @CanIgnoreReturnValue public final ImmutableQueryResults.Builder addNodes(ServiceHealth element)
      Adds one element to nodes list.
      Parameters:
      element - A nodes element
      Returns:
      this builder for use in a chained invocation
    • addNodes

      @CanIgnoreReturnValue public final ImmutableQueryResults.Builder addNodes(ServiceHealth... elements)
      Adds elements to nodes list.
      Parameters:
      elements - An array of nodes elements
      Returns:
      this builder for use in a chained invocation
    • nodes

      @CanIgnoreReturnValue public final ImmutableQueryResults.Builder nodes(Iterable<? extends ServiceHealth> elements)
      Sets or replaces all elements for nodes list.
      Parameters:
      elements - An iterable of nodes elements
      Returns:
      this builder for use in a chained invocation
    • addAllNodes

      @CanIgnoreReturnValue public final ImmutableQueryResults.Builder addAllNodes(Iterable<? extends ServiceHealth> elements)
      Adds elements to nodes list.
      Parameters:
      elements - An iterable of nodes elements
      Returns:
      this builder for use in a chained invocation
    • build

      public ImmutableQueryResults build()
      Builds a new ImmutableQueryResults.
      Returns:
      An immutable instance of QueryResults
      Throws:
      IllegalStateException - if any required attributes are missing