Package org.kiwiproject.registry.client
Class ServiceInstanceFilter
- java.lang.Object
-
- org.kiwiproject.registry.client.ServiceInstanceFilter
-
public class ServiceInstanceFilter extends Object
Utility class that provides version filtering of lists ofServiceInstanceobjects. NOTE: For allListofServiceInstancebeing passed into the utility methods, the assumption is that all instances are for the same service name.
-
-
Constructor Summary
Constructors Constructor Description ServiceInstanceFilter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<ServiceInstance>filterInstancesByVersion(List<ServiceInstance> serviceInstances, RegistryClient.InstanceQuery query)Filter the given service instances using thequery, by minimum and/or preferred versions if specified.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.static booleanversionIsAtLeast(ServiceInstance instance, String version)Is the version of theServiceInstancethe same or higher thanversion?static booleanversionIsExactly(ServiceInstance instance, String version)Is the version of theServiceInstancethe same asversion?
-
-
-
Method Detail
-
filterInstancesByVersion
public static List<ServiceInstance> filterInstancesByVersion(List<ServiceInstance> serviceInstances, RegistryClient.InstanceQuery query)
Filter the given service instances using thequery, 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 theServiceInstancethe same or higher thanversion?- Implementation Note:
- Compares versions using Kiwi's
Versions.isHigherOrSameVersion(String, String)
-
versionIsExactly
public static boolean versionIsExactly(ServiceInstance instance, String version)
Is the version of theServiceInstancethe same asversion?- 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)
-
-