Copyright (c) 2000, 2009 IBM Corporation and others. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ SPDX-License-Identifier: EPL-2.0 Contributors: IBM Corporation - initial API and implementation
/******************************************************************************* * Copyright (c) 2000, 2009 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/
package org.eclipse.jdt.core;
Represents a member-value pair of an annotation. The value is represented by an Object. To get the exact type of this object, use its value kind. If this value is an array, getValue() returns an instance of Object[] and the value kind returns the kind of the elements in this array.

This interface is not intended to be implemented or extended by clients.

Since:3.4
/** * Represents a member-value pair of an annotation. * The {@link #getValue() value} is represented by an {@link Object}. To get the exact * type of this object, use its {@link #getValueKind() value kind}. If this value is an array, * {@link #getValue()} returns an instance of {@link Object}[] and the value kind returns * the kind of the elements in this array. * <p> * This interface is not intended to be implemented or extended by clients. * </p> * * @since 3.4 */
public interface IMemberValuePair {
Constant indicating that the value kind is an int represented by an instance of Integer.
/** * Constant indicating that the value kind is an <code>int</code> represented by * an instance of {@link Integer}. */
int K_INT = 1;
Constant indicating that the value kind is a byte represented by an instance of Byte.
/** * Constant indicating that the value kind is a <code>byte</code> represented by * an instance of {@link Byte}. */
int K_BYTE = 2;
Constant indicating that the value kind is a short represented by an instance of Short.
/** * Constant indicating that the value kind is a <code>short</code> represented by * an instance of {@link Short}. */
int K_SHORT = 3;
Constant indicating that the value kind is a char represented by an instance of Character.
/** * Constant indicating that the value kind is a <code>char</code> represented by * an instance of {@link Character}. */
int K_CHAR = 4;
Constant indicating that the value kind is a float represented by an instance of Float.
/** * Constant indicating that the value kind is a <code>float</code> represented by * an instance of {@link Float}. */
int K_FLOAT = 5;
Constant indicating that the value kind is a double represented by an instance of Double.
/** * Constant indicating that the value kind is a <code>double</code> represented by * an instance of {@link Double}. */
int K_DOUBLE = 6;
Constant indicating that the value kind is a long represented by an instance of Long.
/** * Constant indicating that the value kind is a <code>long</code> represented by * an instance of {@link Long}. */
int K_LONG = 7;
Constant indicating that the value kind is a boolean represented by an instance of Boolean.
/** * Constant indicating that the value kind is a <code>boolean</code> represented by * an instance of {@link Boolean}. */
int K_BOOLEAN = 8;
Constant indicating that the value kind is a String represented by the corresponding String.
/** * Constant indicating that the value kind is a {@link String} represented by * the corresponding {@link String}. */
int K_STRING = 9;
Constant indicating that the value kind is an annotation represented by an instance of IAnnotation.
/** * Constant indicating that the value kind is an annotation represented by * an instance of {@link IAnnotation}. */
int K_ANNOTATION = 10;
Constant indicating that the value kind is a Class represented by the name of the class (i.e. a String. If the member-value pair is coming from a compilation unit, this is either a simple name (e.g. for MyType.class, the name is "MyType"), or a qualified name (e.g. for x.y.MyType.MyNestedType.class, the name is "x.y.MyType.MyNestedType"). If the member-value pair is coming from a class file, this is always a fully qualified name.

Note that one can use IType.resolveType(String) and e.g. IJavaProject.findType(String, String, IProgressMonitor) to find the corresponding IType.

/** * Constant indicating that the value kind is a {@link Class} represented by * the name of the class (i.e. a {@link String}. If the member-value pair is coming from * a compilation unit, this is either a simple name (e.g. for <code>MyType.class</code>, * the name is "MyType"), or a qualified name (e.g. for <code>x.y.MyType.MyNestedType.class</code>, * the name is "x.y.MyType.MyNestedType"). If the member-value pair is coming from a class file, this is * always a fully qualified name. * <p> * Note that one can use {@link IType#resolveType(String)} and e.g. * {@link IJavaProject#findType(String, String, org.eclipse.core.runtime.IProgressMonitor)} * to find the corresponding {@link IType}. * </p> */
int K_CLASS = 11;
Constant indicating that the value is a qualified name represented by a String. The qualified name refers to an enum constant or another compile-time constant if the code is correct (e.g. "MyEnum.FIRST").
/** * Constant indicating that the value is a qualified name represented by a * {@link String}. The qualified name refers to an enum constant or another * compile-time constant if the code is correct (e.g. "MyEnum.FIRST"). */
int K_QUALIFIED_NAME = 12;
Constant indicating that the value is a simple name represented by a String. The simple name refers to an enum constant or another compile-time constant if the code is correct (e.g. "FIRST" when there is a static import for "MyEnum.FIRST").
/** * Constant indicating that the value is a simple name represented by a * {@link String}. The simple name refers to an enum constant or another * compile-time constant if the code is correct (e.g. "FIRST" when there is * a static import for "MyEnum.FIRST"). */
int K_SIMPLE_NAME = 13;
Constant indicating that the value kind is unknown at this stage. The value is unknown in the following cases:
  • the value is an expression that would need to be further analyzed to determine its kind. For example, in @MyAnnot(1 + 2.3) the kind of the expression "1 + 2.3" is unknown
  • the value is an array of size 0, e.g. @MyAnnot({})
  • the value is an array that contains at least one expression that would need to be further analyzed to determine its kind. For example, in @MyAnnot({3.4, 1 + 2.3}), the kind of the second element "1 + 2.3" is unknown.
  • the value is an array that contains heterogeneous values, e.g. @MyAnnot({1, 2.3, "abc"})
If the value kind is unknown, the returned value is always either null, or an array containing Objects and/or nulls for unknown elements.
/** * Constant indicating that the value kind is unknown at this stage. The value is unknown in the * following cases: * <ul> * <li>the value is an expression that would need to be further analyzed to determine its kind. For * example, in <code>@MyAnnot(1 + 2.3)</code> the kind of the expression "1 + 2.3" is * unknown</li> * <li>the value is an array of size 0, e.g. <code>@MyAnnot({})</code></li> * <li>the value is an array that contains at least one expression that would need to be further * analyzed to determine its kind. For example, in <code>@MyAnnot({3.4, 1 + 2.3})</code>, * the kind of the second element "1 + 2.3" is unknown.</li> * <li>the value is an array that contains heterogeneous values, e.g. * <code>@MyAnnot({1, 2.3, "abc"})</code></li> * </ul> * If the value kind is unknown, the returned value is always either <code>null</code>, or an * array containing {@link Object}s and/or <code>null</code>s for unknown elements. */
int K_UNKNOWN = 14;
Returns the member's name of this member-value pair.
Returns:the member's name of this member-value pair.
/** * Returns the member's name of this member-value pair. * * @return the member's name of this member-value pair. */
String getMemberName();
Returns the value of this member-value pair. The type of this value is function of this member-value pair's value kind. It is an instance of Object[] if the value is an array.

If the value kind is K_UNKNOWN and the value is not an array, then the value is null. If the value kind is K_UNKNOWN and the value is an array, then the value is an array containing Objects and/or nulls for unknown elements. See K_UNKNOWN for more details.

Returns:the value of this member-value pair.
/** * Returns the value of this member-value pair. The type of this value * is function of this member-value pair's {@link #getValueKind() value kind}. It is an * instance of {@link Object}[] if the value is an array. * <p> * If the value kind is {@link #K_UNKNOWN} and the value is not an array, then the * value is <code>null</code>. * If the value kind is {@link #K_UNKNOWN} and the value is an array, then the * value is an array containing {@link Object}s and/or <code>null</code>s for * unknown elements. * See {@link #K_UNKNOWN} for more details. * </p> * @return the value of this member-value pair. */
Object getValue();
Returns the value kind of this member-value pair. This indicates the instance of the returned value, or the instance of the elements if the value is an array. The value kind is one of the following constants: K_ANNOTATION, K_BOOLEAN, K_BYTE, K_CHAR, K_CLASS, K_DOUBLE, K_FLOAT, K_INT, K_LONG, K_QUALIFIED_NAME, K_SIMPLE_NAME, K_SHORT, K_STRING, K_UNKNOWN.
Returns:the value kind of this member-value pair
/** * Returns the value kind of this member-value pair. This indicates the instance of * the returned {@link #getValue() value}, or the instance of the elements if the value * is an array. The value kind is one of the following constants: * {@link #K_ANNOTATION}, {@link #K_BOOLEAN}, {@link #K_BYTE}, {@link #K_CHAR}, * {@link #K_CLASS}, {@link #K_DOUBLE}, {@link #K_FLOAT}, {@link #K_INT}, {@link #K_LONG}, * {@link #K_QUALIFIED_NAME}, {@link #K_SIMPLE_NAME}, {@link #K_SHORT}, {@link #K_STRING}, * {@link #K_UNKNOWN}. * * @return the value kind of this member-value pair */
int getValueKind(); }