new ObjectModelAdaptor() {
@Override
public Object getProperty(Interpreter interp, ST self, Object o,
Object property, String propertyName)
throws STNoSuchPropertyException {
ApiDescription apiDescription = (ApiDescription) o;
if ("endpoints".equals(propertyName)) {
Set<EndpointDescription> uniqueEndpoints =
new HashSet<EndpointDescription>(apiDescription.getEndpoints());
List<EndpointDescription> sortedEndpoints = new ArrayList<EndpointDescription>(
uniqueEndpoints);
Collections.sort(sortedEndpoints, new Comparator<EndpointDescription>() {
@Override
public int compare(EndpointDescription e1, EndpointDescription e2) {
return e1.getPath().compareTo(e2.getPath());
}
});
Iterator<EndpointDescription> iter = sortedEndpoints.iterator();
while (iter.hasNext()) {
EndpointDescription ed = iter.next();
if (ed.getPath() != null && ed.getPath().contains("{path:.*}")) {
iter.remove();
}
}
return sortedEndpoints;
}
else if ("flatpackEndpoints".equals(propertyName)) {
List<EndpointDescription> sortedEndpoints = new ArrayList<EndpointDescription>(
apiDescription.getEndpoints());
Collections.sort(sortedEndpoints, new Comparator<EndpointDescription>() {
@Override
public int compare(EndpointDescription e1, EndpointDescription e2) {
return e1.getPath().compareTo(e2.getPath());
}