< prev index next >

src/java.base/share/classes/java/lang/invoke/ConstantGroup.java

Print this page
rev 58552 : [mq]: 8241727-Typos-empty-lines-in-javadoc-inconsistent-indents-etc
   1 /*
   2  * Copyright (c) 2017, 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


 118      * If the constant cannot be resolved, the sentinel will be returned.
 119      * If the constant can (perhaps) be resolved, but has not yet been resolved,
 120      * then the sentinel <em>may</em> be returned, at the implementation's discretion.
 121      * To force resolution (and a possible exception), call {@link #get(int)}.
 122      * @param index the selected constant
 123      * @param ifNotPresent the sentinel value to return if the constant is not present
 124      * @return the selected constant, if available, else the sentinel value
 125      */
 126     Object get(int index, Object ifNotPresent);
 127 
 128     /**
 129      * Returns an indication of whether a constant may be available.
 130      * If it returns {@code true}, it will always return true in the future,
 131      * and a call to {@link #get(int)} will never throw an exception.
 132      * <p>
 133      * After a normal return from {@link #get(int)} or a present
 134      * value is reported from {@link #get(int,Object)}, this method
 135      * must always return true.
 136      * <p>
 137      * If this method returns {@code false}, nothing in particular
 138      *  can be inferred, since the query only concerns the internal
 139      * logic of the {@code ConstantGroup} object which ensures that
 140      a successful * query to a constant will always remain successful.
 141      * The only way to force a permanent decision about whether
 142      * a constant is available is to call {@link #get(int)} and
 143      * be ready for an exception if the constant is unavailable.
 144      * @param index the selected constant
 145      * @return {@code true} if the selected constant is known by
 146      *     this object to be present, {@code false} if it is known
 147      *     not to be present or
 148      */
 149     boolean isPresent(int index);
 150 
 151     /// Views
 152 
 153     /**
 154      * Create a view on this group as a {@link List} view.
 155      * Any request for a constant through this view will
 156      * force resolution.
 157      * @return a {@code List} view on this group which will force resolution
 158      */
 159     default List<Object> asList() {
 160         return new AbstractConstantGroup.AsList(this, 0, size());


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


 118      * If the constant cannot be resolved, the sentinel will be returned.
 119      * If the constant can (perhaps) be resolved, but has not yet been resolved,
 120      * then the sentinel <em>may</em> be returned, at the implementation's discretion.
 121      * To force resolution (and a possible exception), call {@link #get(int)}.
 122      * @param index the selected constant
 123      * @param ifNotPresent the sentinel value to return if the constant is not present
 124      * @return the selected constant, if available, else the sentinel value
 125      */
 126     Object get(int index, Object ifNotPresent);
 127 
 128     /**
 129      * Returns an indication of whether a constant may be available.
 130      * If it returns {@code true}, it will always return true in the future,
 131      * and a call to {@link #get(int)} will never throw an exception.
 132      * <p>
 133      * After a normal return from {@link #get(int)} or a present
 134      * value is reported from {@link #get(int,Object)}, this method
 135      * must always return true.
 136      * <p>
 137      * If this method returns {@code false}, nothing in particular
 138      * can be inferred, since the query only concerns the internal
 139      * logic of the {@code ConstantGroup} object which ensures that
 140      * a successful query to a constant will always remain successful.
 141      * The only way to force a permanent decision about whether
 142      * a constant is available is to call {@link #get(int)} and
 143      * be ready for an exception if the constant is unavailable.
 144      * @param index the selected constant
 145      * @return {@code true} if the selected constant is known by
 146      *     this object to be present, {@code false} if it is known
 147      *     not to be present or
 148      */
 149     boolean isPresent(int index);
 150 
 151     /// Views
 152 
 153     /**
 154      * Create a view on this group as a {@link List} view.
 155      * Any request for a constant through this view will
 156      * force resolution.
 157      * @return a {@code List} view on this group which will force resolution
 158      */
 159     default List<Object> asList() {
 160         return new AbstractConstantGroup.AsList(this, 0, size());


< prev index next >