private static Set<String> calculateRestVersions(Method method) { Set<String> restVersions = Sets.newHashSet(); if (!method.hasAttribute(HttpAttribute.KEY)) { // Return an empty set if the proto method doesn't have http binding. return restVersions; } // Exclude rest version introduced by System APIs. for (String prefix : ConfigRuleSet.SYSTEM_PROTO_PREFIXES) { if (method.getFullName().startsWith(prefix)) { return Collections.emptySet(); } } for (HttpAttribute binding : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { restVersions.add(binding.getRestMethod().getVersionWithDefault()); } return restVersions; } }
private static Set<String> calculateRestVersions(Method method) { Set<String> restVersions = Sets.newHashSet(); if (!method.hasAttribute(HttpAttribute.KEY)) { // Return an empty set if the proto method doesn't have http binding. return restVersions; } // Exclude rest version introduced by System APIs. for (String prefix : ConfigRuleSet.SYSTEM_PROTO_PREFIXES) { if (method.getFullName().startsWith(prefix)) { return Collections.emptySet(); } } for (HttpAttribute binding : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { restVersions.add(binding.getRestMethod().getVersionWithDefault()); } return restVersions; } }
/** * Return the list of API versions for all reachable API methods. */ public static List<String> getReachableRestVersions(Model model) { Set<String> versions = Sets.newLinkedHashSet(); for (Interface iface : model.getSymbolTable().getInterfaces()) { for (Method method : iface.getReachableMethods()) { if (method.hasAttribute(HttpAttribute.KEY)) { for (HttpAttribute binding : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { versions.add(binding.getRestMethod().getVersionWithDefault()); } } } } List<String> versionsList = Lists.newArrayList(versions); Collections.sort(versionsList, Collections.reverseOrder(new VersionComparator())); return versionsList; } }
/** * Return the list of API versions for all reachable API methods. */ public static List<String> getReachableRestVersions(Model model) { Set<String> versions = Sets.newLinkedHashSet(); for (Interface iface : model.getSymbolTable().getInterfaces()) { for (Method method : iface.getReachableMethods()) { if (method.hasAttribute(HttpAttribute.KEY)) { for (HttpAttribute binding : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { versions.add(binding.getRestMethod().getVersionWithDefault()); } } } } List<String> versionsList = Lists.newArrayList(versions); Collections.sort(versionsList, Collections.reverseOrder(new VersionComparator())); return versionsList; } }
@Override public void run(Method method) { if (!method.hasAttribute(HttpAttribute.KEY)) { return; } Set<String> visitedFieldNames = Sets.newHashSet(); for (HttpAttribute httpAttribute : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { for (FieldSelector fieldSelector : httpAttribute.getParamSelectors()) { String restParameterName = fieldSelector.getLastField().getJsonName(); if (!visitedFieldNames.contains(restParameterName)) { visitedFieldNames.add(restParameterName); if (SystemParameter.isSystemParameter(restParameterName)) { warning( method.getLocation(), "Field name '%s' is a reserved keyword, please use a different name. " + "The reserved keywords are %s.", restParameterName, Joiner.on(", ").join(SystemParameter.allSystemParameters()).toLowerCase()); } } } } } }
@Override public void run(Method method) { if (!method.hasAttribute(HttpAttribute.KEY)) { return; } Set<String> visitedFieldNames = Sets.newHashSet(); for (HttpAttribute httpAttribute : method.getAttribute(HttpAttribute.KEY).getAllBindings()) { for (FieldSelector fieldSelector : httpAttribute.getParamSelectors()) { String restParameterName = fieldSelector.getLastField().getJsonName(); if (!visitedFieldNames.contains(restParameterName)) { visitedFieldNames.add(restParameterName); if (SystemParameter.isSystemParameter(restParameterName)) { warning( method.getLocation(), "Field name '%s' is a reserved keyword, please use a different name. " + "The reserved keywords are %s.", restParameterName, Joiner.on(", ").join(SystemParameter.allSystemParameters()).toLowerCase()); } } } } } }