@Override public String getSimpleName() { return method.getSimpleName(); }
@Override public String getRawName() { return method.getSimpleName(); }
@Override public String getSimpleName() { return method.getSimpleName(); }
@Override public String getSimpleName() { return method.getSimpleName(); }
@Override public Name asName() { return Name.upperCamel(method.getSimpleName()); }
/** Returns the GapicMethodConfig for the given method. */ public GapicMethodConfig getMethodConfig(Method method) { return getMethodConfig(method.getSimpleName()); }
continue; methodConfigMapBuilder.put(method.getSimpleName(), methodConfig);
if (methodRetryNames.containsKey(method.getSimpleName())) { methodRetryNames.put(method.getSimpleName(), retryCodesName);
Method oldMethod = methodByName.put(method.getSimpleName(), method); if (oldMethod != null) { model method.getLocation(), "Duplicate declaration of method '%s'. Previous location: %s", method.getSimpleName(), oldMethod.getLocation().getDisplayString())); List<Method> allMethodsOfName = methods.get(method.getSimpleName()); if (allMethodsOfName == null) { methods.put(method.getSimpleName(), Lists.newArrayList(method)); } else { allMethodsOfName.add(method);
static RestMethod createCustomMethod( Method method, HttpAttribute httpConfig, String customNamePrefix) { ImmutableList<PathSegment> path = httpConfig.getFlatPath(); PathSegment lastSegment = path.get(path.size() - 1); // Determine base name. String customName = ""; if (lastSegment instanceof LiteralSegment) { customName = ((LiteralSegment) lastSegment).getLiteral(); path = path.subList(0, path.size() - 1); } else { if (method.getModel().getConfigVersion() > 1) { // From version 2 on, we generate a meaningful name here. customName = method.getSimpleName(); } else if (customNamePrefix.isEmpty()){ // Older versions use the prefix or derive from the http method. customName = httpConfig.getMethodKind().toString().toLowerCase(); } } // Prepend prefix. if (!customNamePrefix.isEmpty() && !customName.toLowerCase().startsWith(customNamePrefix.toLowerCase())) { customName = customNamePrefix + ensureUpperCase(customName); } // Ensure effective start is lower case. customName = ensureLowerCase(customName); String restMethodName = ""; CollectionName collectionName = RestAnalyzer.buildCollectionName(path, method.getModel()); return RestMethod.create( method, RestKind.CUSTOM, collectionName, customName, restMethodName); }
Method oldMethod = methodByName.put(method.getSimpleName(), method); if (oldMethod != null) { model method.getLocation(), "Duplicate declaration of method '%s'. Previous location: %s", method.getSimpleName(), oldMethod.getLocation().getDisplayString())); List<Method> allMethodsOfName = methods.get(method.getSimpleName()); if (allMethodsOfName == null) { methods.put(method.getSimpleName(), Lists.newArrayList(method)); } else { allMethodsOfName.add(method);
static RestMethod createCustomMethod( Method method, HttpAttribute httpConfig, String customNamePrefix) { ImmutableList<PathSegment> path = httpConfig.getFlatPath(); PathSegment lastSegment = path.get(path.size() - 1); // Determine base name. String customName = ""; if (lastSegment instanceof LiteralSegment) { customName = ((LiteralSegment) lastSegment).getLiteral(); path = path.subList(0, path.size() - 1); } else { if (method.getModel().getConfigVersion() > 1) { // From version 2 on, we generate a meaningful name here. customName = method.getSimpleName(); } else if (customNamePrefix.isEmpty()){ // Older versions use the prefix or derive from the http method. customName = httpConfig.getMethodKind().toString().toLowerCase(); } } // Prepend prefix. if (!customNamePrefix.isEmpty() && !customName.toLowerCase().startsWith(customNamePrefix.toLowerCase())) { customName = customNamePrefix + ensureUpperCase(customName); } // Ensure effective start is lower case. customName = ensureLowerCase(customName); String restMethodName = ""; CollectionName collectionName = RestAnalyzer.buildCollectionName(path, method.getModel()); return RestMethod.create( method, RestKind.CUSTOM, collectionName, customName, restMethodName); }
nameMatcher = pattern.nameRegexp().matcher(method.getSimpleName()); if (!nameMatcher.matches()) { return;
nameMatcher = pattern.nameRegexp().matcher(method.getSimpleName()); if (!nameMatcher.matches()) { return;
getHttpRule(method.getOptionFields()) .toBuilder() .setSelector(String.format("%s.%s", interfaceName, method.getSimpleName())) .build();
@BeforeClass public static void startUp() { Mockito.when(httpGetMethod.getSimpleName()).thenReturn(GET_HTTP_METHOD_NAME); Mockito.when(nonIdempotentMethod.getSimpleName()).thenReturn(NON_IDEMPOTENT_METHOD_NAME); Mockito.when(permissionDeniedMethod.getSimpleName()).thenReturn(PERMISSION_DENIED_METHOD_NAME);
private void startMergeMethod(Interface including, Method method) { // Check conditions implied by mixin configuration. Method redeclared = including.lookupMethod(method.getSimpleName()); if (redeclared == null) { error( including.getLocation(), "The API '%s' does not redeclare method '%s' as required by the mixin configuration.", including.getFullName(), method); return; } if (!method.getInputType().equals(redeclared.getInputType())) { error( redeclared.getLocation(), "The method '%s' must have request type '%s' as required by the mixin configuration.", redeclared, method.getInputMessage()); return; } if (!method.getOutputType().equals(redeclared.getOutputType())) { error( redeclared.getLocation(), "The method '%s' must have response type '%s' as required by the mixin configuration.", redeclared, method.getOutputType()); return; } // Add attribute. redeclared.addAttribute(ImplementsAttribute.KEY, ImplementsAttribute.create(method)); }
private void startMergeMethod(Interface including, Method method) { // Check conditions implied by mixin configuration. Method redeclared = including.lookupMethod(method.getSimpleName()); if (redeclared == null) { error( including.getLocation(), "The API '%s' does not redeclare method '%s' as required by the mixin configuration.", including.getFullName(), method); return; } if (!method.getInputType().equals(redeclared.getInputType())) { error( redeclared.getLocation(), "The method '%s' must have request type '%s' as required by the mixin configuration.", redeclared, method.getInputMessage()); return; } if (!method.getOutputType().equals(redeclared.getOutputType())) { error( redeclared.getLocation(), "The method '%s' must have response type '%s' as required by the mixin configuration.", redeclared, method.getOutputType()); return; } // Add attribute. redeclared.addAttribute(ImplementsAttribute.KEY, ImplementsAttribute.create(method)); }
@VisitsBefore void normalize(Interface iface) { Api.Builder coreApiBuilder = Api.newBuilder().setName(iface.getFullName()); coreApiBuilder.setSourceContext( SourceContext.newBuilder().setFileName(iface.getFile().getLocation().getDisplayString())); coreApiBuilder.setSyntax(iface.getSyntax()); for (Method method : iface.getReachableMethods()) { com.google.protobuf.Method.Builder coreMethodBuilder = com.google.protobuf.Method.newBuilder() .setName(method.getSimpleName()) .setRequestTypeUrl(generateTypeUrl(method.getInputType())) .setResponseTypeUrl(generateTypeUrl(method.getOutputType())); coreMethodBuilder.setRequestStreaming(method.getRequestStreaming()); coreMethodBuilder.setResponseStreaming(method.getResponseStreaming()); coreMethodBuilder.addAllOptions( DescriptorNormalization.getMethodOptions( method.getOptionFields(), false, includeDefaults)); coreApiBuilder.addMethods(coreMethodBuilder); } coreApiBuilder.addAllOptions( DescriptorNormalization.getOptions(iface.getProto(), includeDefaults)); coreApiBuilder.setVersion(iface.getAttribute(VersionAttribute.KEY).majorVersion()); apis.add(coreApiBuilder.build()); }
@VisitsBefore void normalize(Interface iface) { Api.Builder coreApiBuilder = Api.newBuilder().setName(iface.getFullName()); coreApiBuilder.setSourceContext( SourceContext.newBuilder().setFileName(iface.getFile().getLocation().getDisplayString())); coreApiBuilder.setSyntax(iface.getSyntax()); for (Method method : iface.getReachableMethods()) { com.google.protobuf.Method.Builder coreMethodBuilder = com.google.protobuf.Method.newBuilder() .setName(method.getSimpleName()) .setRequestTypeUrl(generateTypeUrl(method.getInputType())) .setResponseTypeUrl(generateTypeUrl(method.getOutputType())); coreMethodBuilder.setRequestStreaming(method.getRequestStreaming()); coreMethodBuilder.setResponseStreaming(method.getResponseStreaming()); coreMethodBuilder.addAllOptions( DescriptorNormalization.getMethodOptions( method.getOptionFields(), false, includeDefaults)); coreApiBuilder.addMethods(coreMethodBuilder); } coreApiBuilder.addAllOptions( DescriptorNormalization.getOptions(iface.getProto(), includeDefaults)); coreApiBuilder.setVersion(iface.getAttribute(VersionAttribute.KEY).majorVersion()); apis.add(coreApiBuilder.build()); }