blob: 76dae01b637cb77e2d9d26d21a6f5f066ccaf047 [file] [log] [blame]
Toshio Koideca0fcff2014-10-23 14:08:36 -07001package org.onlab.onos.net.resource;
2
3import java.util.Collection;
4import java.util.Collections;
5import java.util.Map;
6import java.util.Set;
7
8import org.onlab.onos.net.Link;
9import org.onlab.onos.net.intent.IntentId;
10
11/**
12 * Implementation of {@link LinkResourceAllocations}.
13 */
14public class DefaultLinkResourceAllocations implements LinkResourceAllocations {
15 private final LinkResourceRequest request;
16 private final Map<Link, Set<ResourceAllocation>> allocations;
17
18 /**
19 * Creates a new link resource allocations.
20 *
21 * @param request requested resources
22 * @param allocations allocated resources
23 */
24 protected DefaultLinkResourceAllocations(LinkResourceRequest request,
25 Map<Link, Set<ResourceAllocation>> allocations) {
26 this.request = request;
27 this.allocations = allocations;
28 }
29
30 @Override
31 public IntentId intendId() {
32 return request.intendId();
33 }
34
35 @Override
36 public Collection<Link> links() {
37 return request.links();
38 }
39
40 @Override
41 public Set<ResourceRequest> resources() {
42 return request.resources();
43 }
44
45 @Override
46 public ResourceType type() {
47 return null;
48 }
49
50 @Override
51 public Set<ResourceAllocation> getResourceAllocation(Link link) {
52 Set<ResourceAllocation> result = allocations.get(link);
53 if (result == null) {
54 result = Collections.emptySet();
55 }
56 return result;
57 }
58
59}