@Test public void accumulateImplicitUriParametersFromParent() throws Exception { when(one.name()).thenReturn("id"); when(two.name()).thenReturn("color"); when(three.name()).thenReturn("goo"); when(topResource.relativePath()).thenReturn("/fun/{id}/{color}"); when(topResource.uriParameters()).thenReturn(Arrays.asList(one, two)); when(resource.parentResource()).thenReturn(topResource); when(resource.relativePath()).thenReturn("/{goo}"); when(resource.uriParameters()).thenReturn(Collections.singletonList(three)); List<GParameter> parameters = ResourceUtils.accumulateUriParameters(resource); assertEquals(3, parameters.size()); assertEquals("id", parameters.get(0).name()); assertEquals("color", parameters.get(1).name()); assertEquals("goo", parameters.get(2).name()); }
public static List<GParameter> accumulateUriParameters(GResource resource) { Set<String> seenHere = extractSeen(new HashSet<String>(), resource); List<GParameter> parameters = new ArrayList<>(); parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).toList())); while (resource.parentResource() != null) { resource = resource.parentResource(); Set<String> seenInParent = extractSeen(seenHere, resource); final Set<String> finalSeenHere = seenHere; parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).filter(new Predicate<GParameter>() { @Override public boolean apply(@Nullable GParameter gParameter) { return !finalSeenHere.contains(gParameter.name()); } }).toList())); seenHere = seenInParent; } Collections.reverse(parameters); return parameters; }
ResourceUtils { public static List<GParameter> accumulateUriParameters(GResource resource) { Set<String> seenHere = extractSeen(new HashSet<String>(), resource); List<GParameter> parameters = new ArrayList<>(); parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).toList())); while (resource.parentResource() != null) { resource = resource.parentResource(); Set<String> seenInParent = extractSeen(seenHere, resource); final Set<String> finalSeenHere = seenHere; parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).filter(new Predicate<GParameter>() { @Override public boolean apply(@Nullable GParameter gParameter) { return !finalSeenHere.contains(gParameter.name()); } }).toList())); seenHere = seenInParent; } Collections.reverse(parameters); return parameters; } }
ResourceUtils { public static List<GParameter> accumulateUriParameters(GResource resource) { Set<String> seenHere = extractSeen(new HashSet<String>(), resource); List<GParameter> parameters = new ArrayList<>(); parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).toList())); while (resource.parentResource() != null) { resource = resource.parentResource(); Set<String> seenInParent = extractSeen(seenHere, resource); final Set<String> finalSeenHere = seenHere; parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).filter(new Predicate<GParameter>() { @Override public boolean apply(@Nullable GParameter gParameter) { return !finalSeenHere.contains(gParameter.name()); } }).toList())); seenHere = seenInParent; } Collections.reverse(parameters); return parameters; }  }
ResourceUtils { public static List<GParameter> accumulateUriParameters(GResource resource) { Set<String> seenHere = extractSeen(new HashSet<String>(), resource); List<GParameter> parameters = new ArrayList<>(); parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).toList())); while (resource.parentResource() != null) { resource = resource.parentResource(); Set<String> seenInParent = extractSeen(seenHere, resource); final Set<String> finalSeenHere = seenHere; parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).filter(new Predicate<GParameter>() { @Override public boolean apply(@Nullable GParameter gParameter) { return !finalSeenHere.contains(gParameter.name()); } }).toList())); seenHere = seenInParent; } Collections.reverse(parameters); return parameters; }  static void fillInBodiesAndResponses(GResource resource,
                                              Multimap<GMethod, GRequest> incomingBodies, Multimap<GMethod, GResponse> responses); static List<GParameter> accumulateUriParameters(GResource resource); }
ResourceUtils { public static List<GParameter> accumulateUriParameters(GResource resource) { Set<String> seenHere = extractSeen(new HashSet<String>(), resource); List<GParameter> parameters = new ArrayList<>(); parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).toList())); while (resource.parentResource() != null) { resource = resource.parentResource(); Set<String> seenInParent = extractSeen(seenHere, resource); final Set<String> finalSeenHere = seenHere; parameters.addAll(Lists.reverse(FluentIterable.from(resource.uriParameters()).filter(new Predicate<GParameter>() { @Override public boolean apply(@Nullable GParameter gParameter) { return !finalSeenHere.contains(gParameter.name()); } }).toList())); seenHere = seenInParent; } Collections.reverse(parameters); return parameters; }  static void fillInBodiesAndResponses(GResource resource,
                                              Multimap<GMethod, GRequest> incomingBodies, Multimap<GMethod, GResponse> responses); static List<GParameter> accumulateUriParameters(GResource resource);  }