use of java.lang.reflect.Field in project bazel by bazelbuild.
the class OptionsParserImpl method asListOfEffectiveOptions.
/**
* Implements {@link OptionsParser#asListOfEffectiveOptions()}.
*/
List<OptionValueDescription> asListOfEffectiveOptions() {
List<OptionValueDescription> result = Lists.newArrayList();
for (Map.Entry<String, Field> mapEntry : optionsData.getAllNamedFields()) {
String fieldName = mapEntry.getKey();
Field field = mapEntry.getValue();
OptionValueDescription entry = parsedValues.get(field);
if (entry == null) {
Object value = optionsData.getDefaultValue(field);
result.add(new OptionValueDescription(fieldName, value, OptionPriority.DEFAULT, null, null, null, false));
} else {
result.add(entry);
}
}
return result;
}
use of java.lang.reflect.Field in project bazel by bazelbuild.
the class OptionsUsage method getUsage.
/**
* Given an options class, render the usage string into the usage,
* which is passed in as an argument.
*/
static void getUsage(Class<? extends OptionsBase> optionsClass, StringBuilder usage) {
List<Field> optionFields = Lists.newArrayList(OptionsParser.getAllAnnotatedFields(optionsClass));
Collections.sort(optionFields, BY_NAME);
for (Field optionField : optionFields) {
getUsage(optionField, usage, OptionsParser.HelpVerbosity.LONG);
}
}
use of java.lang.reflect.Field in project bazel by bazelbuild.
the class Resolver method setField.
/** Reflectively set a field. */
private void setField(Object receiver, String fieldName, Object value) throws NoSuchFieldException, IllegalAccessException {
Field f = receiver.getClass().getDeclaredField(fieldName);
f.setAccessible(true);
f.set(receiver, value);
}
use of java.lang.reflect.Field in project bazel by bazelbuild.
the class Resolver method getField.
/** Reflectively get the value of a field. */
private Object getField(Object receiver, String fieldName) throws NoSuchFieldException, IllegalAccessException {
Field f = receiver.getClass().getDeclaredField(fieldName);
f.setAccessible(true);
return f.get(receiver);
}
use of java.lang.reflect.Field in project bazel by bazelbuild.
the class AnalysisMock method get.
public static AnalysisMock get() {
try {
Class<?> providerClass = Class.forName(TestConstants.TEST_ANALYSIS_MOCK);
Field instanceField = providerClass.getField("INSTANCE");
return (AnalysisMock) instanceField.get(null);
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
Aggregations