langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/pubapi/PubVar.java
author vasya
Mon, 14 Dec 2015 20:18:19 +0100
changeset 34752 9c262a013456
parent 31115 8d8e98052d5d
permissions -rw-r--r--
8145342: Some copyright notices are inconsistently and ill formatted Summary: Adjusted formatting of copyright notices. Reviewed-by: darcy, alundblad
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31115
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     1
/*
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     2
 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     4
 *
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    10
 *
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    15
 * accompanied this code).
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    16
 *
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    20
 *
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    23
 * questions.
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    24
 */
34752
9c262a013456 8145342: Some copyright notices are inconsistently and ill formatted
vasya
parents: 31115
diff changeset
    25
31115
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    26
package com.sun.tools.sjavac.pubapi;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    27
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    28
import java.io.Serializable;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    29
import java.util.Optional;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    30
import java.util.Set;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    31
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    32
import javax.lang.model.element.Modifier;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    33
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    34
public class PubVar implements Serializable {
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    35
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    36
    private static final long serialVersionUID = 5806536061153374575L;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    37
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    38
    public final Set<Modifier> modifiers;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    39
    public final TypeDesc type;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    40
    public final String identifier;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    41
    private final String constValue;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    42
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    43
    public PubVar(Set<Modifier> modifiers,
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    44
                  TypeDesc type,
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    45
                  String identifier,
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    46
                  String constValue) {
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    47
        this.modifiers = modifiers;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    48
        this.type = type;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    49
        this.identifier = identifier;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    50
        this.constValue = constValue;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    51
    }
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    52
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    53
    public String getIdentifier() {
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    54
        return identifier;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    55
    }
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    56
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    57
    @Override
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    58
    public boolean equals(Object obj) {
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    59
        if (getClass() != obj.getClass())
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    60
            return false;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    61
        PubVar other = (PubVar) obj;
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    62
        return modifiers.equals(other.modifiers)
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    63
            && type.equals(other.type)
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    64
            && identifier.equals(other.identifier)
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    65
            && getConstValue().equals(other.getConstValue());
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    66
    }
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    67
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    68
    @Override
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    69
    public int hashCode() {
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    70
        return modifiers.hashCode()
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    71
             ^ type.hashCode()
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    72
             ^ identifier.hashCode()
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    73
             ^ getConstValue().hashCode();
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    74
    }
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    75
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    76
    public String toString() {
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    77
        return String.format("%s[modifiers: %s, type: %s, identifier: %s, constValue: %s]",
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    78
                             getClass().getSimpleName(),
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    79
                             modifiers,
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    80
                             type,
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    81
                             identifier,
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    82
                             constValue);
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    83
    }
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    84
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    85
    public Optional<String> getConstValue() {
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    86
        return Optional.ofNullable(constValue);
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    87
    }
8d8e98052d5d 8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
diff changeset
    88
}