Path: blob/master/src/java.compiler/share/classes/javax/lang/model/element/Name.java
41161 views
/*1* Copyright (c) 2006, 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.lang.model.element;2627/**28* An immutable sequence of characters. When created by the same29* implementation, objects implementing this interface must obey the30* general {@linkplain Object#equals equals contract} when compared31* with each other. Therefore, {@code Name} objects from the same32* implementation are usable in collections while {@code Name}s from33* different implementations may not work properly in collections.34*35* <p id="empty_name">An {@linkplain CharSequence#isEmpty() empty}36* {@code Name} has a {@linkplain CharSequence#length() length} of37* zero.38*39* <p>In the context of {@linkplain40* javax.annotation.processing.ProcessingEnvironment annotation41* processing}, the guarantees for "the same" implementation must42* include contexts where the {@linkplain javax.annotation.processing43* API mediated} side effects of {@linkplain44* javax.annotation.processing.Processor processors} could be visible45* to each other, including successive annotation processing46* {@linkplain javax.annotation.processing.RoundEnvironment rounds}.47*48* @author Joseph D. Darcy49* @author Scott Seligman50* @author Peter von der Ahé51* @see javax.lang.model.util.Elements#getName52* @since 1.653*/54public interface Name extends CharSequence {55/**56* Returns {@code true} if the argument represents the same57* name as {@code this}, and {@code false} otherwise.58*59* <p>Note that the identity of a {@code Name} is a function both60* of its content in terms of a sequence of characters as well as61* the implementation which created it.62*63* @param obj the object to be compared with this element64* @return {@code true} if the specified object represents the same65* name as this66* @see Element#equals67*/68boolean equals(Object obj);6970/**71* Obeys the general contract of {@link Object#hashCode Object.hashCode}.72*73* @see #equals74*/75int hashCode();7677/**78* Compares this name to the specified {@code CharSequence}. The result79* is {@code true} if and only if this name represents the same sequence80* of {@code char} values as the specified sequence.81*82* @return {@code true} if this name represents the same sequence83* of {@code char} values as the specified sequence, {@code false}84* otherwise85*86* @param cs The sequence to compare this name against87* @see String#contentEquals(CharSequence)88*/89boolean contentEquals(CharSequence cs);90}919293