All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.groupbyinc.common.config.featureflags.CustomerFeatureFlag Maven / Gradle / Ivy

There is a newer version: 198
Show newest version
package com.groupbyinc.common.config.featureflags;

import org.apache.commons.lang3.StringUtils;

import java.util.function.BiPredicate;
import java.util.function.Predicate;
import java.util.stream.Stream;

/**
 * Created by groupby on 2/25/16.
 */
public abstract class CustomerFeatureFlag implements FeatureFlag {

  public static boolean startsWith(String customerId, String... customerIds) {
    return check(checker(customerId, StringUtils::startsWith), customerIds);
  }

  private static boolean check(Predicate checker, String... customerIds) {
    return Stream.of(customerIds)
        .anyMatch(checker);
  }

  private static Predicate checker(String customerId, BiPredicate predicate) {
    return id -> predicate.test(customerId, id);
  }

  public static boolean matches(String customerId, String... customerIds) {
    return check(checker(customerId, StringUtils::equalsIgnoreCase), customerIds);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy