// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.security.tls.policy; import java.util.Set; /** * @author bjorncs */ public record AuthorizedPeers(Set peerPolicies) { public AuthorizedPeers { peerPolicies = verifyPeerPolicies(peerPolicies); } private static Set verifyPeerPolicies(Set peerPolicies) { long distinctNames = peerPolicies.stream() .map(PeerPolicy::policyName) .distinct() .count(); if (distinctNames != peerPolicies.size()) { throw new IllegalArgumentException("'authorized-peers' contains entries with duplicate names"); } return Set.copyOf(peerPolicies); } }