Java tutorial
/** * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# * This file is part of the LDP4j Project: * http://www.ldp4j.org/ * * Center for Open Middleware * http://www.centeropenmiddleware.com/ * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# * Copyright (C) 2014-2016 Center for Open Middleware. * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# * Artifact : org.ldp4j.tutorial.client:eswc-2015-client:1.0.0 * Bundle : eswc-2015-client-1.0.0.jar * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# */ package org.ldp4j.tutorial.client; import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; public final class ResourceRepository { private final Map<String, Resource> resources; private ResourceRepository() { this.resources = Maps.newLinkedHashMap(); } public Resource createResource(String location) { return new Resource(location); } public Resource resolveResource(String location) { Resource resource = this.resources.get(location); if (resource != null) { resource = new Resource(resource); } return resource; } public void updateResource(Resource resource) { this.resources.put(resource.location(), resource); } public void delete(String location) { this.resources.remove(location); } public static ResourceRepository create() { return new ResourceRepository(); } public List<String> list() { return ImmutableList.copyOf(this.resources.keySet()); } }