use of com.google.api.tools.framework.model.FieldSelector in project toolkit by googleapis.
the class ApiCallableTransformer method populateMethodSelectors.
private List<HttpMethodSelectorView> populateMethodSelectors(SurfaceNamer namer, List<FieldSelector> selectors) {
ImmutableList.Builder<HttpMethodSelectorView> paramSelectors = ImmutableList.builder();
for (FieldSelector fs : selectors) {
HttpMethodSelectorView.Builder methodSelectorView = HttpMethodSelectorView.newBuilder();
methodSelectorView.fullyQualifiedName(Name.anyLower(fs.toString()).toLowerCamel());
ImmutableList.Builder<String> gettersChain = ImmutableList.builder();
ImmutableList.Builder<String> gettersHasChain = ImmutableList.builder();
ProtoField pf = null;
for (Field f : fs.getFields()) {
if (pf != null) {
gettersHasChain.add(namer.getFieldGetFunctionName(pf));
}
pf = new ProtoField(f);
gettersChain.add(namer.getFieldGetFunctionName(pf));
}
methodSelectorView.gettersChain(gettersChain.build());
if (pf != null && pf.getProtoField().getProto().getProto3Optional()) {
gettersHasChain.add(namer.getFieldHasFunctionName(pf));
methodSelectorView.gettersHasChain(gettersHasChain.build());
} else {
methodSelectorView.gettersHasChain(ImmutableList.of());
}
paramSelectors.add(methodSelectorView.build());
}
return paramSelectors.build();
}
Aggregations