Interface Weighted

All Superinterfaces:
Comparable<Weighted>
All Known Subinterfaces:
GeneratedService.Descriptor<T>, ServiceInfo
All Known Implementing Classes:
io.helidon.inject.runtime.AbstractServiceProvider, AccessLogFeature, AccessLogRoutingFeature, ContextFeature, CorsFeature, GzipEncodingProvider, JacksonMediaSupportProvider, JsonbMediaSupportProvider, JsonpMediaSupportProvider, LimitsFeature, ObserveFeature, OciAuthenticationDetailsProvider$$Injection$$Activator, OciAvailabilityDefault$$Injection$$Activator, OciRegionProvider$$Injection$$Activator, OpenApiFeature, SecurityFeature, SecurityHttpFeature

public interface Weighted extends Comparable<Weighted>
Interface to define that this class is a class with weight. One of the uses is for services loaded by a ServiceLoader.

A Weighted with higher weight is more significant than a Weighted with a lower weight.

For cases where weight is the same, implementation must define ordering of such Weighted.

Negative weights are not allowed and services using weight should throw an IllegalArgumentException if such a weight is used (unless such a service documents the specific usage of a negative weight)

A Weighted with weight 2 is more significant (will be returned before) weight 1.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Default weight for any weighted component (whether it implements this interface or uses Weight annotation).
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
     
    default double
    Weight of this class (maybe because it is defined dynamically, so it cannot be defined by an annotation).
  • Field Details

    • DEFAULT_WEIGHT

      static final double DEFAULT_WEIGHT
      Default weight for any weighted component (whether it implements this interface or uses Weight annotation).
      See Also:
  • Method Details

    • weight

      default double weight()
      Weight of this class (maybe because it is defined dynamically, so it cannot be defined by an annotation). If not dynamic, you can use the Weight annotation rather than implementing this interface as long as it is supported by the library using this Weighted.
      Returns:
      the weight of this service, must be a non-negative number
    • compareTo

      default int compareTo(Weighted o)
      Specified by:
      compareTo in interface Comparable<Weighted>