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 ofServiceInstance
objects.NOTE: For all
List
ofServiceInstance
being 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 boolean
versionIsAtLeast(ServiceInstance instance, String version)
Is the version of theServiceInstance
the same or higher thanversion
?static boolean
versionIsExactly(ServiceInstance instance, String version)
Is the version of theServiceInstance
the 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.- Parameters:
serviceInstances
- list of service instances to filterquery
- service instance query object- Returns:
- an immutable list containing instances meeting the version criteria
-
versionIsAtLeast
public static boolean versionIsAtLeast(ServiceInstance instance, String version)
Is the version of theServiceInstance
the same or higher thanversion
?- Parameters:
instance
- the service instance to checkversion
- the version to compare- Returns:
- true if the
instance
version is equal to or greater than the givenversion
, else false - Implementation Note:
- Compares versions using Kiwi's
Versions.isHigherOrSameVersion(String, String)
-
versionIsExactly
public static boolean versionIsExactly(ServiceInstance instance, String version)
Is the version of theServiceInstance
the same asversion
?- Parameters:
instance
- the service instance to checkversion
- the version to compare- Returns:
- true if the
instance
version is equal to the givenversion
, else false - 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.- Parameters:
serviceInstances
- list of service instances to filter- Returns:
- a list containing service instances having the latest version seen in
serviceInstances
- Implementation Note:
- Compares versions using Kiwi's
Versions.versionCompare(String, String)
-
-