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; |
| 32 | private final Set<XosFunctionDescriptor> functions; |
| 33 | |
| 34 | /** |
| 35 | * Constructs a bundle descriptor. |
| 36 | * |
| 37 | * @param id bundle identifier |
| 38 | * @param displayName bundle display name |
| 39 | * @param functions functions that make up this bundle |
| 40 | */ |
| 41 | DefaultBundleDescriptor(String id, String displayName, |
| 42 | XosFunctionDescriptor... functions) { |
| 43 | this.id = id; |
| 44 | this.displayName = displayName; |
| 45 | this.functions = ImmutableSet.copyOf(functions); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | public String id() { |
| 50 | return id; |
| 51 | } |
| 52 | |
| 53 | public String displayName() { |
| 54 | return displayName; |
| 55 | } |
| 56 | |
| 57 | public Set<XosFunctionDescriptor> functions() { |
| 58 | return functions; |
| 59 | } |
Simon Hunt | 41b943e | 2015-05-21 13:52:01 -0700 | [diff] [blame^] | 60 | |
| 61 | @Override |
| 62 | public String toString() { |
| 63 | return "{BundleDescriptor: " + displayName + "}"; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public boolean equals(Object o) { |
| 68 | if (this == o) { |
| 69 | return true; |
| 70 | } |
| 71 | if (o == null || getClass() != o.getClass()) { |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | DefaultBundleDescriptor that = (DefaultBundleDescriptor) o; |
| 76 | return id.equals(that.id); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public int hashCode() { |
| 81 | return id.hashCode(); |
| 82 | } |
Simon Hunt | f844f63 | 2015-05-20 19:06:35 -0700 | [diff] [blame] | 83 | } |