Mercurial > hg > truffle
changeset 12671:582b3d24c6ad
record an OptionDescriptor in an OptionValue so that it can be queried for a name
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 05 Nov 2013 11:14:42 +0100 |
parents | cf57663a2a36 |
children | 38bf986ce231 |
files | graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionDescriptor.java graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java |
diffstat | 2 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionDescriptor.java Tue Nov 05 06:50:16 2013 +0100 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionDescriptor.java Tue Nov 05 11:14:42 2013 +0100 @@ -42,6 +42,7 @@ this.option = option; this.declaringClass = declaringClass; this.fieldName = fieldName; + option.setDescriptor(this); } /**
--- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Tue Nov 05 06:50:16 2013 +0100 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Tue Nov 05 11:14:42 2013 +0100 @@ -32,6 +32,8 @@ */ protected T value; + private OptionDescriptor descriptor; + public OptionValue(T value) { this.value = value; } @@ -55,6 +57,26 @@ } /** + * Sets the descriptor for this option. + */ + public void setDescriptor(OptionDescriptor descriptor) { + this.descriptor = descriptor; + } + + /** + * Gets the name of this option. The name for an option value with a null + * {@linkplain #setDescriptor(OptionDescriptor) descriptor} is {@code "<anonymous>"}. + */ + public String getName() { + return descriptor == null ? "<anonymous>" : (descriptor.getDeclaringClass().getName() + "." + descriptor.getName()); + } + + @Override + public String toString() { + return getName() + "=" + value; + } + + /** * Gets the value of this option. */ public T getValue() {