< prev index next >

src/java.management/share/classes/javax/management/ImmutableDescriptor.java

Print this page


   1 /*
   2  * Copyright (c) 2004, 2015, 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


  35 import java.util.TreeMap;
  36 
  37 /**
  38  * An immutable descriptor.
  39  * @since 1.6
  40  */
  41 public class ImmutableDescriptor implements Descriptor {
  42     private static final long serialVersionUID = 8853308591080540165L;
  43 
  44     /**
  45      * The names of the fields in this ImmutableDescriptor with their
  46      * original case.  The names must be in alphabetical order as determined
  47      * by {@link String#CASE_INSENSITIVE_ORDER}.
  48      */
  49     private final String[] names;
  50     /**
  51      * The values of the fields in this ImmutableDescriptor.  The
  52      * elements in this array match the corresponding elements in the
  53      * {@code names} array.
  54      */

  55     private final Object[] values;
  56 
  57     private transient int hashCode = -1;
  58 
  59     /**
  60      * An empty descriptor.
  61      */
  62     public static final ImmutableDescriptor EMPTY_DESCRIPTOR =
  63             new ImmutableDescriptor();
  64 
  65     /**
  66      * Construct a descriptor containing the given fields and values.
  67      *
  68      * @param fieldNames the field names
  69      * @param fieldValues the field values
  70      * @throws IllegalArgumentException if either array is null, or
  71      * if the arrays have different sizes, or
  72      * if a field name is null or empty, or if the same field name
  73      * appears more than once.
  74      */


   1 /*
   2  * Copyright (c) 2004, 2019, 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


  35 import java.util.TreeMap;
  36 
  37 /**
  38  * An immutable descriptor.
  39  * @since 1.6
  40  */
  41 public class ImmutableDescriptor implements Descriptor {
  42     private static final long serialVersionUID = 8853308591080540165L;
  43 
  44     /**
  45      * The names of the fields in this ImmutableDescriptor with their
  46      * original case.  The names must be in alphabetical order as determined
  47      * by {@link String#CASE_INSENSITIVE_ORDER}.
  48      */
  49     private final String[] names;
  50     /**
  51      * The values of the fields in this ImmutableDescriptor.  The
  52      * elements in this array match the corresponding elements in the
  53      * {@code names} array.
  54      */
  55     @SuppressWarnings("serial") // Conditionally serializable
  56     private final Object[] values;
  57 
  58     private transient int hashCode = -1;
  59 
  60     /**
  61      * An empty descriptor.
  62      */
  63     public static final ImmutableDescriptor EMPTY_DESCRIPTOR =
  64             new ImmutableDescriptor();
  65 
  66     /**
  67      * Construct a descriptor containing the given fields and values.
  68      *
  69      * @param fieldNames the field names
  70      * @param fieldValues the field values
  71      * @throws IllegalArgumentException if either array is null, or
  72      * if the arrays have different sizes, or
  73      * if a field name is null or empty, or if the same field name
  74      * appears more than once.
  75      */


< prev index next >