blob: d5940a9d33057290f82d915578e278dc9ab7e460 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuska58de4162015-09-10 16:15:33 -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 */
Thomas Vachuska6b331262015-04-27 11:09:07 -070016package org.onlab.jdvue;
17
18import java.util.Objects;
19
20/**
21 * Abstraction of a Java source entity.
22 */
23public abstract class JavaEntity {
24
25 private final String name;
26
27 /**
28 * Creates a new Java source entity with the given name.
29 *
30 * @param name source entity name
31 */
32 JavaEntity(String name) {
33 this.name = name;
34 }
35
36 /**
37 * Returns the Java source entity name.
38 *
39 * @return source entity name
40 */
41 public String name() {
42 return name;
43 }
44
45 @Override
46 public boolean equals(Object o) {
47 if (o instanceof JavaEntity) {
48 JavaEntity that = (JavaEntity) o;
49 return getClass().equals(that.getClass()) &&
50 Objects.equals(name, that.name);
51 }
52 return false;
53 }
54
55 @Override
56 public int hashCode() {
57 return Objects.hash(name);
58 }
59}