comparison graal/com.oracle.jvmci.options/src/com/oracle/jvmci/options/OptionDescriptor.java @ 21554:b1530a6cce8c

renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Tue, 26 May 2015 23:21:15 +0200
parents graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionDescriptor.java@e589c26c2eb8
children
comparison
equal deleted inserted replaced
21553:0910a9497b02 21554:b1530a6cce8c
1 /*
2 * Copyright (c) 2013, 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.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23 package com.oracle.jvmci.options;
24
25 /**
26 * Describes the attributes of a static field {@linkplain Option option} and provides access to its
27 * {@linkplain OptionValue value}.
28 */
29 public class OptionDescriptor {
30
31 protected final String name;
32 protected final Class<?> type;
33 protected final String help;
34 protected final OptionValue<?> option;
35 protected final Class<?> declaringClass;
36 protected final String fieldName;
37
38 public OptionDescriptor(String name, Class<?> type, String help, Class<?> declaringClass, String fieldName, OptionValue<?> option) {
39 this.name = name;
40 this.type = type;
41 this.help = help;
42 this.option = option;
43 this.declaringClass = declaringClass;
44 this.fieldName = fieldName;
45 assert !type.isPrimitive() : "must used boxed type instead of " + type;
46 option.setDescriptor(this);
47 }
48
49 /**
50 * Gets the type of values stored in the option. This will be the boxed type for a primitive
51 * option.
52 */
53 public Class<?> getType() {
54 return type;
55 }
56
57 /**
58 * Gets a descriptive help message for the option.
59 */
60 public String getHelp() {
61 return help;
62 }
63
64 /**
65 * Gets the name of the option. It's up to the client of this object how to use the name to get
66 * a user specified value for the option from the environment.
67 */
68 public String getName() {
69 return name;
70 }
71
72 /**
73 * Gets the boxed option value.
74 */
75 public OptionValue<?> getOptionValue() {
76 return option;
77 }
78
79 public Class<?> getDeclaringClass() {
80 return declaringClass;
81 }
82
83 public String getFieldName() {
84 return fieldName;
85 }
86
87 /**
88 * Gets a description of the location where this option is stored.
89 */
90 public String getLocation() {
91 return getDeclaringClass().getName() + "." + getFieldName();
92 }
93 }