blob: 21fae4794f23025424c26c89d43635a7074e2cb5 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
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 */
Thomas Vachuska6b331262015-04-27 11:09:07 -070016package org.onlab.jdvue;
17
18import java.util.Objects;
19
Sho SHIMIZU43748e82015-08-25 10:05:08 -070020import static com.google.common.base.MoreObjects.toStringHelper;
Thomas Vachuska6b331262015-04-27 11:09:07 -070021
22/**
23 * Abstraction of a dependency segment.
24 *
25 * @author Thomas Vachuska
26 */
27public 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}