src/share/classes/sun/security/x509/DistributionPointName.java

Print this page


   1 /*
   2  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 184                     TAG_RELATIVE_NAME),
 185                 theChoice);
 186         }
 187     }
 188 
 189     /**
 190      * Compare an object to this distribution point name for equality.
 191      *
 192      * @param obj Object to be compared to this
 193      * @return true if objects match; false otherwise
 194      */
 195     public boolean equals(Object obj) {
 196         if (this == obj) {
 197             return true;
 198         }
 199         if (obj instanceof DistributionPointName == false) {
 200             return false;
 201         }
 202         DistributionPointName other = (DistributionPointName)obj;
 203 
 204         return equals(this.fullName, other.fullName) &&
 205                equals(this.relativeName, other.relativeName);
 206     }
 207 
 208     /**
 209      * Returns the hash code for this distribution point name.
 210      *
 211      * @return the hash code.
 212      */
 213     public int hashCode() {
 214         int hash = hashCode;
 215         if (hash == 0) {
 216             hash = 1;
 217             if (fullName != null) {
 218                 hash += fullName.hashCode();
 219 
 220             } else {
 221                 hash += relativeName.hashCode();
 222             }
 223             hashCode = hash;
 224         }
 225         return hash;
 226     }
 227 
 228     /**
 229      * Returns a printable string of the distribution point name.
 230      */
 231     public String toString() {
 232         StringBuilder sb = new StringBuilder();
 233         if (fullName != null) {
 234             sb.append("DistributionPointName:\n     " + fullName + "\n");
 235 
 236         } else {
 237             sb.append("DistributionPointName:\n     " + relativeName + "\n");
 238         }
 239 
 240         return sb.toString();
 241     }
 242 
 243     /*
 244      * Utility function for a.equals(b) where both a and b may be null.
 245      */
 246     private static boolean equals(Object a, Object b) {
 247         return (a == null) ? (b == null) : a.equals(b);
 248     }
 249 }
   1 /*
   2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 184                     TAG_RELATIVE_NAME),
 185                 theChoice);
 186         }
 187     }
 188 
 189     /**
 190      * Compare an object to this distribution point name for equality.
 191      *
 192      * @param obj Object to be compared to this
 193      * @return true if objects match; false otherwise
 194      */
 195     public boolean equals(Object obj) {
 196         if (this == obj) {
 197             return true;
 198         }
 199         if (obj instanceof DistributionPointName == false) {
 200             return false;
 201         }
 202         DistributionPointName other = (DistributionPointName)obj;
 203 
 204         return Objects.equals(this.fullName, other.fullName) &&
 205                Objects.equals(this.relativeName, other.relativeName);
 206     }
 207 
 208     /**
 209      * Returns the hash code for this distribution point name.
 210      *
 211      * @return the hash code.
 212      */
 213     public int hashCode() {
 214         int hash = hashCode;
 215         if (hash == 0) {
 216             hash = 1;
 217             if (fullName != null) {
 218                 hash += fullName.hashCode();
 219 
 220             } else {
 221                 hash += relativeName.hashCode();
 222             }
 223             hashCode = hash;
 224         }
 225         return hash;
 226     }
 227 
 228     /**
 229      * Returns a printable string of the distribution point name.
 230      */
 231     public String toString() {
 232         StringBuilder sb = new StringBuilder();
 233         if (fullName != null) {
 234             sb.append("DistributionPointName:\n     " + fullName + "\n");
 235 
 236         } else {
 237             sb.append("DistributionPointName:\n     " + relativeName + "\n");
 238         }
 239 
 240         return sb.toString();
 241     }







 242 }