Last change
on this file since 193 was
193,
checked in by Maciej Komosinski, 10 years ago
|
Set svn:eol-style native for all textual files
|
-
Property svn:eol-style set to
native
|
File size:
1.1 KB
|
Line | |
---|
1 | package com.framsticks.structure; |
---|
2 | |
---|
3 | import javax.annotation.Nonnull; |
---|
4 | import javax.annotation.concurrent.Immutable; |
---|
5 | |
---|
6 | import com.framsticks.params.CompositeParam; |
---|
7 | import com.framsticks.util.FramsticksException; |
---|
8 | // import com.framsticks.params.ParamBuilder; |
---|
9 | import com.framsticks.util.lang.Strings; |
---|
10 | |
---|
11 | /** |
---|
12 | * @author Piotr Sniegowski |
---|
13 | */ |
---|
14 | @Immutable |
---|
15 | public class Node { |
---|
16 | |
---|
17 | protected final Tree tree; |
---|
18 | protected final CompositeParam param; |
---|
19 | protected final Object object; |
---|
20 | |
---|
21 | public Node(Tree tree, @Nonnull CompositeParam param, Object object) { |
---|
22 | assert param != null; |
---|
23 | assert tree != null; |
---|
24 | this.tree = tree; |
---|
25 | this.param = param; |
---|
26 | this.object = object; |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | public final Tree getTree() { |
---|
31 | return tree; |
---|
32 | } |
---|
33 | |
---|
34 | public final CompositeParam getParam() { |
---|
35 | return param; |
---|
36 | } |
---|
37 | |
---|
38 | public final Object getObject() { |
---|
39 | return object; |
---|
40 | } |
---|
41 | |
---|
42 | @Override |
---|
43 | public String toString() { |
---|
44 | return param.toString() + ":" + Strings.toStringNullProof(object, "<null>"); |
---|
45 | } |
---|
46 | |
---|
47 | public final boolean isResolved() { |
---|
48 | return object != null; |
---|
49 | } |
---|
50 | |
---|
51 | public Node assureResolved() { |
---|
52 | if (!isResolved()) { |
---|
53 | throw new FramsticksException().msg("path is not resolved").arg("node", this); |
---|
54 | } |
---|
55 | return this; |
---|
56 | } |
---|
57 | |
---|
58 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.