Simon Hunt | f844f63 | 2015-05-20 19:06:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 3 | * |
| 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 | |
| 18 | package org.onosproject.cord.gui.model; |
| 19 | |
| 20 | import com.google.common.collect.ImmutableSet; |
| 21 | |
| 22 | import java.util.Set; |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * Base implementation of BundleDescriptor. |
| 27 | */ |
| 28 | public class DefaultBundleDescriptor implements BundleDescriptor { |
| 29 | |
| 30 | private final String id; |
| 31 | private final String displayName; |
Simon Hunt | 09a32db | 2015-05-21 15:00:42 -0700 | [diff] [blame] | 32 | private final String description; |
Simon Hunt | f844f63 | 2015-05-20 19:06:35 -0700 | [diff] [blame] | 33 | 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 Hunt | 09a32db | 2015-05-21 15:00:42 -0700 | [diff] [blame] | 42 | DefaultBundleDescriptor(String id, String displayName, String description, |
Simon Hunt | f844f63 | 2015-05-20 19:06:35 -0700 | [diff] [blame] | 43 | XosFunctionDescriptor... functions) { |
| 44 | this.id = id; |
| 45 | this.displayName = displayName; |
Simon Hunt | 09a32db | 2015-05-21 15:00:42 -0700 | [diff] [blame] | 46 | this.description = description; |
Simon Hunt | f844f63 | 2015-05-20 19:06:35 -0700 | [diff] [blame] | 47 | 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 Hunt | 09a32db | 2015-05-21 15:00:42 -0700 | [diff] [blame] | 59 | public String description() { |
| 60 | return description; |
| 61 | } |
| 62 | |
Simon Hunt | f844f63 | 2015-05-20 19:06:35 -0700 | [diff] [blame] | 63 | public Set<XosFunctionDescriptor> functions() { |
| 64 | return functions; |
| 65 | } |
Simon Hunt | 41b943e | 2015-05-21 13:52:01 -0700 | [diff] [blame] | 66 | |
| 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 Hunt | f844f63 | 2015-05-20 19:06:35 -0700 | [diff] [blame] | 89 | } |