Class ServiceInstanceFilter


  • public class ServiceInstanceFilter
    extends Object
    Utility class that provides version filtering of lists of ServiceInstance objects. NOTE: For all List of ServiceInstance being passed into the utility methods, the assumption is that all instances are for the same service name.
    • Constructor Detail

      • ServiceInstanceFilter

        public ServiceInstanceFilter()
    • Method Detail

      • filterInstancesByVersion

        public static List<ServiceInstance> filterInstancesByVersion​(List<ServiceInstance> serviceInstances,
                                                                     RegistryClient.InstanceQuery query)
        Filter the given service instances using the query, by minimum and/or preferred versions if specified.
        Returns:
        an immutable list containing instances meeting the version criteria
      • versionIsAtLeast

        public static boolean versionIsAtLeast​(ServiceInstance instance,
                                               String version)
        Is the version of the ServiceInstance the same or higher than version?
        Implementation Note:
        Compares versions using Kiwi's Versions.isHigherOrSameVersion(String, String)
      • versionIsExactly

        public static boolean versionIsExactly​(ServiceInstance instance,
                                               String version)
        Is the version of the ServiceInstance the same as version?
        Implementation Note:
        Compares versions using Kiwi's Versions.isSameVersion(String, String)
      • findInstancesWithLatestVersion

        public static List<ServiceInstance> findInstancesWithLatestVersion​(List<ServiceInstance> serviceInstances)
        Finds the latest version in the given list of service instances, then returns a new list containing only instances having that latest version.
        Implementation Note:
        Compares versions using Kiwi's Versions.versionCompare(String, String)