Search in sources :

Example 1 with ArgumentDefinition

use of com.yahoo.elide.datastores.aggregation.annotation.ArgumentDefinition in project elide by yahoo.

the class TableType method getArgumentDefinitions.

private static ArgumentDefinition[] getArgumentDefinitions(List<Argument> arguments) {
    int numArguments = arguments == null ? 0 : arguments.size();
    ArgumentDefinition[] definitions = new ArgumentDefinition[numArguments];
    for (int idx = 0; idx < numArguments; idx++) {
        Argument argument = arguments.get(idx);
        definitions[idx] = new ArgumentDefinition() {

            @Override
            public String name() {
                return argument.getName();
            }

            @Override
            public String description() {
                return argument.getDescription();
            }

            @Override
            public ValueType type() {
                return ValueType.valueOf(argument.getType().toUpperCase(Locale.ROOT));
            }

            @Override
            public TableSource tableSource() {
                return buildTableSource(argument.getTableSource());
            }

            @Override
            public String[] values() {
                return argument.getValues().toArray(new String[0]);
            }

            @Override
            public String defaultValue() {
                Object value = argument.getDefaultValue();
                return value == null ? null : value.toString();
            }

            @Override
            public Class<? extends Annotation> annotationType() {
                return ArgumentDefinition.class;
            }
        };
    }
    return definitions;
}
Also used : TableSource(com.yahoo.elide.datastores.aggregation.annotation.TableSource) Argument(com.yahoo.elide.modelconfig.model.Argument) ValueType(com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType) ArgumentDefinition(com.yahoo.elide.datastores.aggregation.annotation.ArgumentDefinition) Annotation(java.lang.annotation.Annotation)

Aggregations

ArgumentDefinition (com.yahoo.elide.datastores.aggregation.annotation.ArgumentDefinition)1 TableSource (com.yahoo.elide.datastores.aggregation.annotation.TableSource)1 ValueType (com.yahoo.elide.datastores.aggregation.metadata.enums.ValueType)1 Argument (com.yahoo.elide.modelconfig.model.Argument)1 Annotation (java.lang.annotation.Annotation)1