Path: blob/master/src/java.naming/share/classes/javax/naming/ldap/spi/LdapDnsProviderResult.java
41161 views
/*1* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.naming.ldap.spi;2627import java.util.List;2829/**30* The result of a DNS lookup for an LDAP URL.31*32* <p> This class is used by an {@link LdapDnsProvider} to return the result33* of a DNS lookup for a given LDAP URL. The result consists of a domain name34* and its associated LDAP server endpoints.35*36* <p> A {@code null} {@code domainName} is equivalent to and represented37* by an empty string.38*39* @since 1240*/41public final class LdapDnsProviderResult {4243private final String domainName;44private final List<String> endpoints;4546/**47* Construct an LdapDnsProviderResult consisting of a resolved domain name48* and the LDAP server endpoints that serve the domain.49*50* @param domainName the resolved domain name; can be null.51* @param endpoints the possibly empty list of resolved LDAP server52* endpoints53*54* @throws NullPointerException if {@code endpoints} contains {@code null}55* elements.56* @throws ClassCastException if {@code endpoints} contains non-57* {@code String} elements.58*/59public LdapDnsProviderResult(String domainName, List<String> endpoints) {60this.domainName = (domainName == null) ? "" : domainName;61this.endpoints = List.copyOf(endpoints);62}6364/**65* Returns the domain name resolved from the LDAP URL. This method returns66* the empty string if the {@code LdapDnsProviderResult} is created with a67* null domain name.68*69* @return the resolved domain name70*/71public String getDomainName() {72return domainName;73}7475/**76* Returns the possibly empty list of individual server endpoints resolved77* from the LDAP URL.78*79* @return a possibly empty unmodifiable {@link List} containing the80* resolved LDAP server endpoints81*/82public List<String> getEndpoints() {83return endpoints;84}85}868788