Beispiel #1
0
 /**
  * Creates a JsonHome document from a collection of ResourceLinks. The link-relation types of the
  * resources must be unique, otherwise an IllegalArgumentException is thrown.
  *
  * @param resources collection of resource links.
  * @return JsonHome
  */
 public static JsonHome jsonHome(final Collection<? extends ResourceLink> resources) {
   final Map<URI, ResourceLink> resourceMap = new HashMap<URI, ResourceLink>(resources.size());
   for (final ResourceLink resource : resources) {
     if (resourceMap.containsKey(resource.getLinkRelationType())) {
       throw new IllegalArgumentException(
           "Unable to construct JsonHome. Link-relation types must be unique.");
     }
     resourceMap.put(resource.getLinkRelationType(), resource);
   }
   return new JsonHome(resourceMap);
 }
 public JsonHomeBuilder addResources(final Collection<ResourceLink> resources) {
   for (final ResourceLink resource : resources) {
     this.resources.put(resource.getLinkRelationType(), resource);
   }
   return this;
 }
 public JsonHomeBuilder addResource(final ResourceLink resource) {
   this.resources.put(resource.getLinkRelationType(), resource);
   return this;
 }