@Test public void testCanonicalNameMap() { RoleDimensionMapping rdMap = new RoleDimensionMapping("x(.+)y.*", null, ImmutableMap.of("border", "something")); Set<String> nodes = ImmutableSet.of("xbordery", "core", "xbordery2", "xcorey"); SortedMap<String, String> nodeRolesMap = rdMap.createNodeRolesMap(nodes); assertThat( nodeRolesMap, equalTo( ImmutableSortedMap.of( "xbordery", "something", "xbordery2", "something", "xcorey", "core"))); }
public SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames) { SortedMap<String, String> m = new TreeMap<>(); for (String node : nodeNames) { Optional<String> optRoleName = roleNameForNode(node); optRoleName.ifPresent(roleName -> m.put(node, roleName)); } return m; }
RoleDimensionMapping implements Comparable<RoleDimensionMapping> { public SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames) { SortedMap<String, String> m = new TreeMap<>(); for (String node : nodeNames) { Optional<String> optRoleName = roleNameForNode(node); optRoleName.ifPresent(roleName -> m.put(node, roleName)); } return m; } }
RoleDimensionMapping implements Comparable<RoleDimensionMapping> { public SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames) { SortedMap<String, String> m = new TreeMap<>(); for (String node : nodeNames) { Optional<String> optRoleName = roleNameForNode(node); optRoleName.ifPresent(roleName -> m.put(node, roleName)); } return m; } @JsonCreator  RoleDimensionMapping(
      @JsonProperty(PROP_REGEX) String regex,
      @JsonProperty(PROP_GROUPS) @Nullable List<Integer> groups,
      @JsonProperty(PROP_CANONICAL_ROLE_NAMES) @Nullable Map<String, String> canonicalRoleNames);  RoleDimensionMapping(String regex);  RoleDimensionMapping(NodeRole role); }
RoleDimensionMapping implements Comparable<RoleDimensionMapping> { public SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames) { SortedMap<String, String> m = new TreeMap<>(); for (String node : nodeNames) { Optional<String> optRoleName = roleNameForNode(node); optRoleName.ifPresent(roleName -> m.put(node, roleName)); } return m; } @JsonCreator  RoleDimensionMapping(
      @JsonProperty(PROP_REGEX) String regex,
      @JsonProperty(PROP_GROUPS) @Nullable List<Integer> groups,
      @JsonProperty(PROP_CANONICAL_ROLE_NAMES) @Nullable Map<String, String> canonicalRoleNames);  RoleDimensionMapping(String regex);  RoleDimensionMapping(NodeRole role); @Override int compareTo(RoleDimensionMapping o); @Override boolean equals(Object o); @JsonProperty(PROP_CANONICAL_ROLE_NAMES) @Nonnull Map<String, String> getCanonicalRoleNames(); @JsonProperty(PROP_GROUPS) @Nonnull List<Integer> getGroups(); @JsonProperty(PROP_REGEX) @Nonnull String getRegex(); SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames); @Override int hashCode(); @Override String toString(); }
RoleDimensionMapping implements Comparable<RoleDimensionMapping> { public SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames) { SortedMap<String, String> m = new TreeMap<>(); for (String node : nodeNames) { Optional<String> optRoleName = roleNameForNode(node); optRoleName.ifPresent(roleName -> m.put(node, roleName)); } return m; } @JsonCreator  RoleDimensionMapping(
      @JsonProperty(PROP_REGEX) String regex,
      @JsonProperty(PROP_GROUPS) @Nullable List<Integer> groups,
      @JsonProperty(PROP_CANONICAL_ROLE_NAMES) @Nullable Map<String, String> canonicalRoleNames);  RoleDimensionMapping(String regex);  RoleDimensionMapping(NodeRole role); @Override int compareTo(RoleDimensionMapping o); @Override boolean equals(Object o); @JsonProperty(PROP_CANONICAL_ROLE_NAMES) @Nonnull Map<String, String> getCanonicalRoleNames(); @JsonProperty(PROP_GROUPS) @Nonnull List<Integer> getGroups(); @JsonProperty(PROP_REGEX) @Nonnull String getRegex(); SortedMap<String, String> createNodeRolesMap(Set<String> nodeNames); @Override int hashCode(); @Override String toString();  }