Repository navigation
Expand file tree
/
Copy pathAppCodeScannerBase.java
More file actions
74 lines (59 loc) · 1.68 KB
/
Copy pathAppCodeScannerBase.java
File metadata and controls
74 lines (59 loc) · 1.68 KB
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
package act.app;
import act.conf.AppConfig;
import org.osgl.$;
import org.osgl.logging.L;
import org.osgl.logging.Logger;
import org.osgl.util.E;
import org.osgl.util.S;
/**
* Base class for {@link AppCodeScanner} implementations
*/
public abstract class AppCodeScannerBase implements AppCodeScanner {
protected static Logger logger = L.get(AppCodeScanner.class);
private App app;
@Override
public final void setApp(App app) {
E.NPE(app);
E.illegalStateIf(null != this.app && this.app != app, "%s has already been stamped", this);
this.app = app;
onAppSet();
}
protected void onAppSet() {}
@Override
public final boolean start(String className) {
if (!shouldScan(className)) {
return false;
}
reset();
reset(className);
return true;
}
protected final App app() {
return app;
}
protected final AppConfig config() {
return app().config();
}
protected abstract void reset();
protected void reset(String className) {}
protected abstract boolean shouldScan(String className);
@Override
public int hashCode() {
return $.hc(app, getClass());
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof AppCodeScannerBase) {
AppCodeScannerBase that = (AppCodeScannerBase) obj;
return (that.app == app && that.getClass() == getClass());
}
return false;
}
@Override
public String toString() {
return S.builder(getClass().getName()).append("[").append(app).append("]").toString();
}
}