Search in sources :

Example 1 with VersionRange

use of org.bf2.cos.fleetshard.api.VersionRange in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class OperatorSelectorUtil method available.

public static Optional<Operator> available(OperatorSelector selector, Collection<Operator> operators) {
    if (operators == null) {
        return Optional.empty();
    }
    if (operators.isEmpty()) {
        return Optional.empty();
    }
    final VersionRange range = new VersionRange(selector.getVersion());
    final Comparator<Operator> cmp = Comparator.comparing(o -> new Version(o.getVersion()));
    return operators.stream().filter(o -> Objects.equals(o.getType(), selector.getType())).filter(o -> versionInRange(range, o)).max(cmp);
}
Also used : Operator(org.bf2.cos.fleetshard.api.Operator) Objects(java.util.Objects) Logger(org.slf4j.Logger) Collection(java.util.Collection) Version(org.bf2.cos.fleetshard.api.Version) LoggerFactory(org.slf4j.LoggerFactory) Optional(java.util.Optional) VersionRange(org.bf2.cos.fleetshard.api.VersionRange) Operator(org.bf2.cos.fleetshard.api.Operator) Comparator(java.util.Comparator) OperatorSelector(org.bf2.cos.fleetshard.api.OperatorSelector) Version(org.bf2.cos.fleetshard.api.Version) VersionRange(org.bf2.cos.fleetshard.api.VersionRange)

Aggregations

Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Operator (org.bf2.cos.fleetshard.api.Operator)1 OperatorSelector (org.bf2.cos.fleetshard.api.OperatorSelector)1 Version (org.bf2.cos.fleetshard.api.Version)1 VersionRange (org.bf2.cos.fleetshard.api.VersionRange)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1