1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.commons.pkg;
21
22 public abstract class AbstractDependencyNode implements DependencyNode
23 {
24
25 private Object id;
26 private boolean required;
27
28 public AbstractDependencyNode(Object id)
29 {
30 this.id = id;
31 }
32
33 public Object getID()
34 {
35 return id;
36 }
37
38 public boolean isRequired()
39 {
40 return required;
41 }
42
43 public void require(boolean requireInstalled)
44 throws UnsatisfiedDependenciesException
45 {
46 if (required) {
47
48 return;
49 }
50
51 required = true;
52 try {
53 checkDepends(requireInstalled);
54 }
55 catch (UnsatisfiedDependenciesException e) {
56 required = false;
57 throw e;
58 }
59 }
60
61 public abstract void checkDepends(boolean requireInstalled)
62 throws UnsatisfiedDependenciesException;
63
64 public void setRequired(boolean required)
65 {
66 this.required = required;
67 }
68
69 public String toString()
70 {
71 return getID().toString();
72 }
73
74 }
75