@Override public void run() { Preconditions.checkArgument( !ran, "%s:%s: only one field of OutputSpec may be set", context.getMethodModel().getSimpleName(), valueSet.getId()); ran = true; } };
public SampleSpec(MethodConfigProto methodConfigProto) { specified = methodConfigProto.hasSamples(); sampleConfiguration = methodConfigProto.getSamples(); valueSets = methodConfigProto.getSampleValueSetsList(); HashSet<String> ids = new HashSet<>(); for (SampleValueSet valueSet : valueSets) { String id = valueSet.getId(); if (!ids.add(id)) { throw new IllegalArgumentException( String.format( "in method \"%s\": duplicate value set id: \"%s\"", methodConfigProto.getName(), id)); } } }
private OutputView.PrintView printView( List<String> config, MethodContext context, SampleValueSet valueSet, ScopeTable localVars) { Preconditions.checkArgument( !config.isEmpty(), "%s:%s: print spec cannot be empty", context.getMethodModel().getSimpleName(), valueSet.getId()); return OutputView.PrintView.newBuilder() .format(context.getNamer().getPrintSpec(config.get(0))) .args( config .subList(1, config.size()) .stream() .map( a -> printArgTransformer.generatePrintArg( context, accessor(new Scanner(a), context, valueSet, localVars))) .collect(ImmutableList.toImmutableList())) .build(); }
for (SampleTypeConfiguration sample : matchingSamples) { for (String valueSetExpression : sample.getValueSetsList()) { if (expressionMatchesId(valueSetExpression, vset.getId())) { result.add( ValueSetAndTags.newBuilder().values(vset).regionTag(sample.getRegionTag()).build());
"%s:%s: one field of OutputSpec must be set", context.getMethodModel().getSimpleName(), valueSet.getId());
private OutputView.DefineView defineView( Scanner definition, MethodContext context, SampleValueSet valueSet, ScopeTable localVars) { Preconditions.checkArgument( definition.scan() == Scanner.IDENT, "%s:%s: expected identifier: %s", context.getMethodModel().getSimpleName(), valueSet.getId(), definition.input()); String identifier = definition.tokenStr(); assertIdentifierNotReserved( identifier, context.getMethodModel().getSimpleName(), valueSet.getId()); Preconditions.checkArgument( definition.scan() == '=', "%s:%s invalid definition, expecting '=': %s", context.getMethodModel().getSimpleName(), valueSet.getId(), definition.input()); OutputView.VariableView reference = accessorNewVariable(definition, context, valueSet, localVars, identifier, false); return OutputView.DefineView.newBuilder() .variableType(localVars.getTypeName(identifier)) .variableName(context.getNamer().localVarName(Name.from(identifier))) .reference(reference) .build(); }
public static SampleValueSetView of(SampleValueSet config) { SampleValueSetView.Builder builder = new AutoValue_SampleValueSetView.Builder(); return builder .id(config.getId()) .title(config.getTitle()) .description(config.getDescription()) .parameters(config.getParameters().getDefaultsList()) .build(); }
"%s:%s: expected identifier: %s", context.getMethodModel().getSimpleName(), valueSet.getId(), config.input()); String baseIdentifier = config.tokenStr(); "%s:%s: variable not defined: %s", context.getMethodModel().getSimpleName(), valueSet.getId(), baseIdentifier); "%s:%s: accessing a field of a resource name is not currently supported", context.getMethodModel().getSimpleName(), valueSet.getId()); Preconditions.checkArgument( type.isMessage(), "%s:%s: %s is not a message", context.getMethodModel().getSimpleName(), valueSet.getId(), config.input()); Preconditions.checkArgument( "%s:%s: %s is not scalar", context.getMethodModel().getSimpleName(), valueSet.getId(), config.input()); "%s:%s: expected identifier: %s", context.getMethodModel().getSimpleName(),
private OutputView.LoopView loopView( OutputSpec.LoopStatement loop, MethodContext context, SampleValueSet valueSet, ScopeTable localVars) { ScopeTable scope = localVars.newChild(); String loopVariable = loop.getVariable(); assertIdentifierNotReserved( loopVariable, context.getMethodModel().getSimpleName(), valueSet.getId()); OutputView.VariableView accessor = accessorNewVariable( new Scanner(loop.getCollection()), context, valueSet, scope, loopVariable, true); OutputView.LoopView ret = OutputView.LoopView.newBuilder() .variableType(scope.getTypeName(loopVariable)) .variableName(context.getNamer().localVarName(Name.from(loopVariable))) .collection(accessor) .body( loop.getBodyList() .stream() .map(body -> toView(body, context, valueSet, scope)) .collect(ImmutableList.toImmutableList())) .build(); return ret; }
methodContext.getMethodModel().getSimpleName(), form, valueSet.getId())) .sampleFunctionName( methodContext.getNamer().getSampleFunctionName(methodContext.getMethodModel()))