source: java/main/src/main/java/com/framsticks/test/TestClass.java @ 105

Last change on this file since 105 was 105, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • import refactorization: move Tree, Path, etc.

from core to structure package

  • initial serialization implementation
  • improve PrimeExperiment? test
  • many organizational changes and convenience improvements

CHANGELOG:
Make registry in AbstractTree? final.

Move most classes from core to structure package.

Minor changes.

Switch names of Future and FutureHandler?.

Rename ExceptionResultHandler? to ExceptionHandler?.

Rename ExceptionHandler? to ExceptionDispatcherHandler?.

Fix bug in ParamCandidate? cache.

Add missing synchronization to the BufferedDispatcher?.

Develop @Serialized support.

Rework serialization further.

Add serialization/deserialization interface to ValueParam?.

Move getStorageType and isNumeric from Param down to params hierarchy.

Minor changes.

Improve param type induction.

Add TestSerializedClass? for testing new serialization.

Add info files gor GenePool? and Population.

Add standard.expt exemplary netfile.

Add type name field to PropertiesObject?.

Use PropertiesObject? for PropertiesAccess? instead of ordinary map.

Hide getFramsClass is several more places.

More unification accross FramsClass?, Access and Path.

Add ParamCollection?.

Simplify interface for getting params from FramsClass?, Access
or Path.

Make Access.call() interface variadic.

Add arguments(args) convenience wrapper around new Object[] {args}.

Upgrade to apache.commons.lang version 3.1

Minor improvement with Response constructors.

Develop proper result printing in ClientAtServer?.

Add experimentNetsave to PrimeExperiment?.

File size: 3.0 KB
Line 
1package com.framsticks.test;
2
3import java.util.Map;
4
5import org.apache.logging.log4j.Logger;
6import org.apache.logging.log4j.LogManager;
7
8import com.framsticks.params.EventListener;
9import com.framsticks.params.SimplePrimitive;
10import com.framsticks.params.SimpleUniqueList;
11import com.framsticks.params.annotations.AutoAppendAnnotation;
12import com.framsticks.params.annotations.FramsClassAnnotation;
13import com.framsticks.params.annotations.ParamAnnotation;
14import com.framsticks.params.types.ProcedureParam;
15import com.framsticks.structure.messages.ListChange;
16import com.framsticks.structure.messages.ValueChange;
17
18@FramsClassAnnotation(
19        order = {
20                "name",
21                "history",
22                "history_changed",
23                "appendHistory",
24                "resetHistory",
25                "children",
26                "createChild",
27                "children_changed"
28        }
29)
30public class TestClass {
31        private static final Logger log = LogManager.getLogger(TestClass.class);
32
33
34        protected String name = "test";
35        protected final SimplePrimitive<String> history = new SimplePrimitive<>("initial|");
36
37        protected final SimpleUniqueList<TestChild> children = new SimpleUniqueList<>(TestChild.class, 'c');
38
39        /**
40         *
41         */
42        public TestClass() {
43        }
44
45        /**
46         * @return the name
47         */
48        @ParamAnnotation
49        public String getName() {
50                return name;
51        }
52
53        /**
54         * @param name the name to set
55         */
56        @ParamAnnotation
57        public void setName(String name) {
58                this.name = name;
59        }
60
61        /**
62         * @return the history
63         */
64        @ParamAnnotation
65        public String getHistory() {
66                return history.get();
67        }
68
69        /**
70         * @param history the history to set
71         */
72        @ParamAnnotation
73        public void setHistory(String history) {
74                this.history.set(history);
75        }
76
77        /**
78         * @return the children
79         */
80        @ParamAnnotation
81        public Map<String, TestChild> getChildren() {
82                return children.getMap();
83        }
84
85        @ParamAnnotation(paramType = ProcedureParam.class)
86        public int appendHistory(String line) {
87                log.debug("appending '{}'", line);
88                history.set(history.get() + line + "|");
89                // fireHistoryChange();
90                return history.get().length();
91        }
92
93        @ParamAnnotation(paramType = ProcedureParam.class)
94        public void resetHistory() {
95                log.debug("reseting");
96                history.set("");
97        }
98
99        @ParamAnnotation(paramType = ProcedureParam.class)
100        public void createChild(String name) {
101                TestChild child = new TestChild();
102                child.name = name;
103                addChild(child);
104        }
105
106        @AutoAppendAnnotation
107        public void addChild(TestChild child) {
108                child.parent = this;
109                children.add(child);
110        }
111
112        @ParamAnnotation(id = "history_changed")
113        public void addHistoryListener(EventListener<ValueChange> listener) {
114                history.addListener(listener);
115        }
116
117        @ParamAnnotation(id = "history_changed")
118        public void removeHistoryListener(EventListener<ValueChange> listener) {
119                history.removeListener(listener);
120        }
121
122        @ParamAnnotation(id = "children_changed")
123        public void addChildrenListener(EventListener<ListChange> listener) {
124                children.addListener(listener);
125        }
126
127        @ParamAnnotation(id = "children_changed")
128        public void removeChildrenListener(EventListener<ListChange> listener) {
129                children.removeListener(listener);
130        }
131
132        @Override
133        public String toString() {
134                return "test class " + history;
135        }
136
137
138}
Note: See TracBrowser for help on using the repository browser.