source: java/main/src/main/java/com/framsticks/params/Param.java @ 96

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

HIGHLIGHTS:

  • cleanup Instance management
    • extract Instance interface
    • extract Instance common algorithms to InstanceUtils?
  • fix closing issues: Ctrl+C or window close button

properly shutdown whole program

by Java Framsticks framework

  • fix parsing and printing of all request types
  • hide exception passing in special handle method of closures
    • substantially improve readability of closures
    • basically enable use of exception in asynchronous closures

(thrown exception is transported back to the caller)

  • implement call request on both sides

CHANGELOG:
Further improve calling.

Improve instance calling.

Calling is working on both sides.

Improve exception handling in testing.

Waiters do not supercede other apllication exception being thrown.

Finished parsing and printing of all request types (with tests).

Move implementation and tests of request parsing to Request.

Add tests for Requests.

Improve waits in asynchronours tests.

Extract more algorithms to InstanceUtils?.

Extract Instance.resolve to InstanceUtils?.

Improve naming.

Improve passing exception in InstanceClient?.

Hide calling of passed functor in StateCallback?.

Hide Exception passing in asynchronous closures.

Hide exception passing in Future.

Make ResponseCallback? an abstract class.

Make Future an abstract class.

Minor change.

Move getPath to Path.to()

Move bindAccess to InstanceUtils?.

Extract common things to InstanceUtils?.

Fix synchronization bug in Connection.

Move resolve to InstanceUtils?.

Allow names of Joinable to be dynamic.

Add support for set request server side.

More fixes in communication.

Fix issues with parsing in connection.

Cut new line characters when reading.

More improvements.

Migrate closures to FramsticksException?.

Several changes.

Extract resolveAndFetch to InstanceUtils? algorithms.

Test resolving and fetching.

More fixes with function signature deduction.

Do not print default values in SimpleAbstractAccess?.

Add test of FramsClass? printing.

Improve FramsticksException? messages.

Add explicit dispatcher synchronization feature.

Rework assertions in tests.

Previous solution was not generic enough.

Allow addition of joinables to collection after start.

Extract SimulatorInstance? from RemoteInstance?.

Remove PrivateJoinableCollection?.

Improve connections.

Move shutdown hook to inside the Monitor.

It should work in TestNG tests, but it seems that
hooks are not called.

In ServerTest? client connects to testing server.

Move socket initialization to receiver thread.

Add proper closing on Ctrl+C (don't use signals).

Fix bugs with server accepting connections.

Merge Entity into Joinable.

Reworking ServerInstance?.

Extract more algorithm to InstanceUtils?.

Extract some common functionality from AbstractInstance?.

Functions were placed in InstanceUtils?.

Hide registry of Instance.

Use ValueParam? in Instance interface.

Minor change.

Extract Instance interface.

Old Instance is now AbstractInstance?.

File size: 2.3 KB
Line 
1package com.framsticks.params;
2
3
4import javax.annotation.concurrent.Immutable;
5
6import com.framsticks.params.annotations.FramsClassAnnotation;
7import com.framsticks.params.annotations.ParamAnnotation;
8
9/**
10 * Based on c++ struct ParamEntry located in cpp/gdk/param.h
11 * Here  it is a root of Param hierarchy.
12 *
13 * @author Jarek Szymczak <name.surname@gmail.com>, Mateusz Jarus
14 * (please replace name and surname with my personal data)
15 *
16 * @author Piotr Śniegowski
17 */
18@Immutable
19@FramsClassAnnotation(id = "prop", name = "prop", order = {"id", "name", "type", "flags", "help", "group", "extra"})
20public abstract class Param {
21
22        /** The parameter id. */
23        protected final String id;
24
25        /** The parameter name. */
26        protected final String name;
27
28        /** The help (description) concerning parameter. */
29        protected final String help;
30
31        /** The number of group, that parameter belongs to. */
32        protected final Integer group;
33
34        /** The getFlags stored as a bit sum. */
35        protected final int flags;
36
37        //TODO
38        /** The variable determining whether the parameter is an extra parameter. */
39        protected final int extra;
40
41        public Param(ParamBuilder builder) {
42                id = builder.getId();
43                name = builder.getName();
44                help = builder.getHelp();
45                group = builder.getGroup();
46                flags = builder.getFlags();
47                extra = builder.getExtra();
48        }
49
50        @ParamAnnotation
51        public String getId() {
52                return id;
53        }
54
55        @ParamAnnotation
56        public String getName() {
57                return name;
58        }
59
60        @ParamAnnotation
61        public String getHelp() {
62                return help;
63        }
64
65        @ParamAnnotation
66        public Integer getGroup() {
67                return group;
68        }
69
70        @ParamAnnotation(def = "0")
71        public Integer getFlags() {
72                return flags;
73        }
74
75        @ParamAnnotation(id = "type")
76        public abstract String getFramsTypeName();
77
78        @ParamAnnotation
79        public Integer getExtra() {
80                return extra;
81        }
82
83        @Override
84        public String toString() {
85                return getId() + ":" + this.getClass().getSimpleName();
86        }
87
88        public boolean isNumeric() {
89                return false;
90        }
91
92        public abstract Class<?> getStorageType();
93
94        public boolean hasFlag(int flag) {
95                return (flags & flag) != 0;
96        }
97
98        public boolean isUserHidden() {
99                return (flags & Flags.USERHIDDEN) != 0;
100        }
101
102        public static ParamBuilder build() {
103                return new ParamBuilder();
104        }
105
106        public static ParamBuilder build(FramsClassBuilder builder) {
107                return new ParamBuilder(builder);
108        }
109
110}
Note: See TracBrowser for help on using the repository browser.