Class TenantRangeParser

java.lang.Object
fr.gouv.vitam.common.model.config.TenantRangeParser

public final class TenantRangeParser extends Object
  • Method Details

    • parseTenantRanges

      public static List<TenantRange> parseTenantRanges(String tenantRanges) throws IllegalStateException
      Throws:
      IllegalStateException
    • doRangesIntersect

      public static boolean doRangesIntersect(TenantRange tenantRange1, TenantRange tenantRange2)
    • expandTenantSet

      public static Set<Integer> expandTenantSet(String contractedTenants)
      Expands every range of a single contracted expression (e.g. "0,1,3-10") into a sorted set of tenant ids. A single value (e.g. "3") yields a one-element set, preserving backward compatibility.
    • expandTenantIds

      public static List<Integer> expandTenantIds(String contractedTenants)
      Expands a contracted expression (e.g. "0,1,3-10") into a sorted, deduplicated list of tenant ids. Returns null when the input is null.
    • expandTenantObjectList

      public static <T, V> Map<Integer,V> expandTenantObjectList(List<T> items, Function<T,String> tenantRangeExtractor, Function<T,V> valueMapper)
      Expands a list of objects, each carrying a contracted tenant range, into a Map<tenantId, value>. Replaces the Collectors.toMap(...::getTenantRange, ...) pattern while supporting ranges.
      Throws:
      IllegalStateException - if a tenant id is covered by more than one entry.
    • expandTenantKeyedMap

      public static <V> Map<Integer,V> expandTenantKeyedMap(Map<String,V> contracted)
      Expands a map whose keys are contracted tenant expressions (e.g. "5-10") into a Map<tenantId, value>. A plain integer key (e.g. "3") keeps working, preserving backward compatibility.
      Throws:
      IllegalStateException - if a tenant id is covered by more than one key.