Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 | */ |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 16 | package org.onlab.jdvue; |
| 17 | |
| 18 | import java.util.Objects; |
| 19 | |
Sho SHIMIZU | 43748e8 | 2015-08-25 10:05:08 -0700 | [diff] [blame] | 20 | import static com.google.common.base.MoreObjects.toStringHelper; |
Thomas Vachuska | 6b33126 | 2015-04-27 11:09:07 -0700 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * Abstraction of a dependency segment. |
| 24 | * |
| 25 | * @author Thomas Vachuska |
| 26 | */ |
| 27 | public class Dependency { |
| 28 | |
| 29 | private final JavaPackage source; |
| 30 | private final JavaPackage target; |
| 31 | |
| 32 | /** |
| 33 | * Creates a dependency from the specified source on the given target. |
| 34 | * |
| 35 | * @param source source of the dependency |
| 36 | * @param target target of the dependency |
| 37 | */ |
| 38 | public Dependency(JavaPackage source, JavaPackage target) { |
| 39 | this.source = source; |
| 40 | this.target = target; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Returns the dependency source. |
| 45 | * |
| 46 | * @return source Java package |
| 47 | */ |
| 48 | public JavaPackage getSource() { |
| 49 | return source; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Returns the dependency target. |
| 54 | * |
| 55 | * @return target Java package |
| 56 | */ |
| 57 | public JavaPackage getTarget() { |
| 58 | return target; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean equals(Object obj) { |
| 63 | if (obj instanceof Dependency) { |
| 64 | Dependency that = (Dependency) obj; |
| 65 | return Objects.equals(source, that.source) && |
| 66 | Objects.equals(target, that.target); |
| 67 | } |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public int hashCode() { |
| 73 | return Objects.hash(source, target); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public String toString() { |
| 78 | return toStringHelper(this) |
| 79 | .add("source", source).add("target", target).toString(); |
| 80 | } |
| 81 | |
| 82 | } |