src/share/jaxws_classes/com/sun/codemodel/internal/JArrayClass.java

Thu, 12 Oct 2017 19:44:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 19:44:07 +0800
changeset 760
e530533619ec
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2010, 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
    23  * questions.
    24  */
    26 package com.sun.codemodel.internal;
    28 import java.util.Iterator;
    29 import java.util.Collections;
    30 import java.util.List;
    32 /**
    33  * Array class.
    34  *
    35  * @author
    36  *      Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
    37  */
    38 final class JArrayClass extends JClass {
    40     // array component type
    41     private final JType componentType;
    44     JArrayClass( JCodeModel owner, JType component ) {
    45         super(owner);
    46         this.componentType = component;
    47     }
    50     public String name() {
    51         return componentType.name()+"[]";
    52     }
    54     public String fullName() {
    55         return componentType.fullName()+"[]";
    56     }
    58     public String binaryName() {
    59         return componentType.binaryName()+"[]";
    60     }
    62     public void generate(JFormatter f) {
    63         f.g(componentType).p("[]");
    64     }
    66     public JPackage _package() {
    67         return owner().rootPackage();
    68     }
    70     public JClass _extends() {
    71         return owner().ref(Object.class);
    72     }
    74     public Iterator<JClass> _implements() {
    75         return Collections.<JClass>emptyList().iterator();
    76     }
    78     public boolean isInterface() {
    79         return false;
    80     }
    82     public boolean isAbstract() {
    83         return false;
    84     }
    86     public JType elementType() {
    87         return componentType;
    88     }
    90     public boolean isArray() {
    91         return true;
    92     }
    95     //
    96     // Equality is based on value
    97     //
    99     public boolean equals(Object obj) {
   100         if(!(obj instanceof JArrayClass))   return false;
   102         if( componentType.equals( ((JArrayClass)obj).componentType ) )
   103             return true;
   105         return false;
   106     }
   108     public int hashCode() {
   109         return componentType.hashCode();
   110     }
   112     protected JClass substituteParams(JTypeVar[] variables, List<JClass> bindings) {
   113         if( componentType.isPrimitive() )
   114             return this;
   116         JClass c = ((JClass)componentType).substituteParams(variables,bindings);
   117         if(c==componentType)
   118             return this;
   120         return new JArrayClass(owner(),c);
   121     }
   123 }

mercurial