@Test public void testDispatchLinkCollection() { List<String> refs = new ArrayList<>(); refs.add("test"); refs.add("gugus"); Map<String, List<HalReference>> links = new HashMap<>(); HalReferenceMetaData metaData = new HalReferenceMetaData(); metaData.setName("self"); adapter.dispatchLink(refs, metaData, links); Assert.assertEquals(1, links.size()); List<HalReference> link = links.get("self"); Assert.assertNotNull(link); Assert.assertEquals(2, link.size()); Assert.assertEquals("test", link.get(0).getHref()); Assert.assertEquals("gugus", link.get(1).getHref()); }
protected void dispatchLink(Object value, HalReferenceMetaData metaData, Map<String, List<HalReference>> links) { if (value == null) { return; } if (value instanceof HalReference) { readLink((HalReference) value, metaData, links); } else if (value instanceof Collection) { readLinkCollection((Collection<?>) value, metaData, links); } else { readLinkObject(value, metaData, links); } }
HalSerializer implements JsonSerializer<HalResource> { protected void dispatchLink(Object value, HalReferenceMetaData metaData, Map<String, List<HalReference>> links) { if (value == null) { return; } if (value instanceof HalReference) { readLink((HalReference) value, metaData, links); } else if (value instanceof Collection) { readLinkCollection((Collection<?>) value, metaData, links); } else { readLinkObject(value, metaData, links); } } }
HalSerializer implements JsonSerializer<HalResource> { protected void dispatchLink(Object value, HalReferenceMetaData metaData, Map<String, List<HalReference>> links) { if (value == null) { return; } if (value instanceof HalReference) { readLink((HalReference) value, metaData, links); } else if (value instanceof Collection) { readLinkCollection((Collection<?>) value, metaData, links); } else { readLinkObject(value, metaData, links); } }  }
HalSerializer implements JsonSerializer<HalResource> { protected void dispatchLink(Object value, HalReferenceMetaData metaData, Map<String, List<HalReference>> links) { if (value == null) { return; } if (value instanceof HalReference) { readLink((HalReference) value, metaData, links); } else if (value instanceof Collection) { readLinkCollection((Collection<?>) value, metaData, links); } else { readLinkObject(value, metaData, links); } }  @Override JsonElement serialize(HalResource t, Type type, JsonSerializationContext jsc); }
HalSerializer implements JsonSerializer<HalResource> { protected void dispatchLink(Object value, HalReferenceMetaData metaData, Map<String, List<HalReference>> links) { if (value == null) { return; } if (value instanceof HalReference) { readLink((HalReference) value, metaData, links); } else if (value instanceof Collection) { readLinkCollection((Collection<?>) value, metaData, links); } else { readLinkObject(value, metaData, links); } }  @Override JsonElement serialize(HalResource t, Type type, JsonSerializationContext jsc);  }