File: JGraphSQLEntity.java

package info (click to toggle)
libjgraph-java 5.12.4.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 7,884 kB
  • ctags: 7,321
  • sloc: java: 20,619; xml: 135; sh: 51; makefile: 10
file content (83 lines) | stat: -rw-r--r-- 1,597 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * $Id: JGraphSQLEntity.java,v 1.1.1.1 2005/08/06 05:26:45 gaudenz Exp $
 * 
 * Copyright (c) 2001-2005, Gaudenz Alder
 * 
 * See LICENSE file in distribution for licensing details of this source file
 */
package com.jgraph.example.adapter;

/**
 * An object that represents an entity in a tree.
 */
public class JGraphSQLEntity extends JGraphBusinessObject {

	protected Object id;

	protected JGraphSQLEntity parent;

	public JGraphSQLEntity() {
		this(null);
	}

	public JGraphSQLEntity(Object userObject) {
		this(userObject, null, null);
	}

	public JGraphSQLEntity(Object id, JGraphSQLEntity parent) {
		this(null, id, parent);
	}

	public JGraphSQLEntity(Object userObject, Object id, JGraphSQLEntity parent) {
		super(userObject);
		setID(id);
		setParent(parent);
	}

	/**
	 * @return Returns the id.
	 */
	public Object getID() {
		return id;
	}

	/**
	 * @param id
	 *            The id to set.
	 */
	public void setID(Object id) {
		this.id = id;
	}

	/**
	 * @return Returns the parent.
	 */
	public JGraphSQLEntity getParent() {
		return parent;
	}

	/**
	 * @param parent
	 *            The parent to set.
	 */
	public void setParent(JGraphSQLEntity parent) {
		this.parent = parent;
	}

	public Object clone() {
		JGraphSQLEntity entity = (JGraphSQLEntity) super.clone();
		entity.setID(null);
		return entity;
	}

	public int hashCode() {
		return (id != null) ? id.hashCode() : super.hashCode();
	}

	public boolean equals(Object other) {
		if (id != null && other instanceof JGraphSQLEntity)
			return ((JGraphSQLEntity) other).getID().equals(getID());
		return false;
	}

}