Class MetadataBuilder

java.lang.Object
org.eclipse.microprofile.metrics.MetadataBuilder

public class MetadataBuilder extends Object
The Metadata builder. All values are considered "not present" by default. Name must be set before build() is called.
  • Constructor Details

    • MetadataBuilder

      public MetadataBuilder()
  • Method Details

    • withName

      public MetadataBuilder withName(String name)
      Sets the name. Does not accept null.
      Parameters:
      name - the name
      Returns:
      the builder instance
      Throws:
      NullPointerException - when name is null
      IllegalArgumentException - when name is empty
    • withDescription

      public MetadataBuilder withDescription(String description)
      Sets the description.
      Parameters:
      description - the name, empty string is considered as "not present" (null)
      Returns:
      the builder instance
    • withUnit

      public MetadataBuilder withUnit(String unit)
      Sets the unit.
      Parameters:
      unit - the unit, MetricUnits.NONE is considered as "not present" (null)
      Returns:
      the builder instance
    • build

      public Metadata build()
      Returns:
      An object implementing Metadata from the provided properties
      Throws:
      IllegalStateException - when either name is null