blob: 06db9d1693879e2c5b94fabde232673188353aac [file] [log] [blame]
Simon Huntf844f632015-05-20 19:06:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Huntf844f632015-05-20 19:06:35 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.onosproject.cord.gui.model;
19
20import com.google.common.collect.ImmutableSet;
21
22import java.util.Set;
23
24
25/**
26 * Base implementation of BundleDescriptor.
27 */
28public class DefaultBundleDescriptor implements BundleDescriptor {
29
30 private final String id;
31 private final String displayName;
Simon Hunt09a32db2015-05-21 15:00:42 -070032 private final String description;
Simon Huntf844f632015-05-20 19:06:35 -070033 private final Set<XosFunctionDescriptor> functions;
34
35 /**
36 * Constructs a bundle descriptor.
37 *
38 * @param id bundle identifier
39 * @param displayName bundle display name
40 * @param functions functions that make up this bundle
41 */
Simon Hunt09a32db2015-05-21 15:00:42 -070042 DefaultBundleDescriptor(String id, String displayName, String description,
Simon Huntf844f632015-05-20 19:06:35 -070043 XosFunctionDescriptor... functions) {
44 this.id = id;
45 this.displayName = displayName;
Simon Hunt09a32db2015-05-21 15:00:42 -070046 this.description = description;
Simon Huntf844f632015-05-20 19:06:35 -070047 this.functions = ImmutableSet.copyOf(functions);
48 }
49
50
51 public String id() {
52 return id;
53 }
54
55 public String displayName() {
56 return displayName;
57 }
58
Simon Hunt09a32db2015-05-21 15:00:42 -070059 public String description() {
60 return description;
61 }
62
Simon Huntf844f632015-05-20 19:06:35 -070063 public Set<XosFunctionDescriptor> functions() {
64 return functions;
65 }
Simon Hunt41b943e2015-05-21 13:52:01 -070066
67 @Override
68 public String toString() {
69 return "{BundleDescriptor: " + displayName + "}";
70 }
71
72 @Override
73 public boolean equals(Object o) {
74 if (this == o) {
75 return true;
76 }
77 if (o == null || getClass() != o.getClass()) {
78 return false;
79 }
80
81 DefaultBundleDescriptor that = (DefaultBundleDescriptor) o;
82 return id.equals(that.id);
83 }
84
85 @Override
86 public int hashCode() {
87 return id.hashCode();
88 }
Simon Huntf844f632015-05-20 19:06:35 -070089}