source: java/main/src/main/java/com/framsticks/params/types/ObjectParam.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: 1.4 KB
Line 
1package com.framsticks.params.types;
2
3import com.framsticks.params.Access;
4import com.framsticks.params.CastFailure;
5import com.framsticks.params.CompositeParam;
6import com.framsticks.params.ParamBuilder;
7import com.framsticks.params.ParamsUtil;
8import com.framsticks.params.ReassignResult;
9
10import javax.annotation.concurrent.Immutable;
11
12/**
13 * @author Piotr Sniegowski
14 */
15@Immutable
16public class ObjectParam extends CompositeParam {
17
18        protected final Class<?> storageType;
19
20        public ObjectParam(ParamBuilder builder) {
21                super(builder.fillStorageType(Object.class));
22                storageType = builder.getStorageType();
23        }
24
25        @Override
26        public String computeAccessId() {
27                return containedTypeName;
28        }
29
30        @Override
31        public Class<?> getStorageType() {
32                return storageType;
33        }
34
35        @Override
36        public ReassignResult<Object> reassign(Object newValue, Object oldValue) throws CastFailure {
37                if (newValue != null && !storageType.isInstance(newValue)) {
38                        throw new CastFailure();
39                }
40                return ReassignResult.create(newValue);
41        }
42
43        @Override
44        public Access prepareAccess(Access access) {
45                return access;
46        }
47
48        @Override
49        public String getFramsTypeName() {
50                return "o " + containedTypeName;
51        }
52
53        @Override
54        public <T> String serialize(T value) {
55                return ParamsUtil.serialize(value);
56        }
57
58        @Override
59        public <T> T deserialize(String text, T currentValue, Class<T> type) {
60                return ParamsUtil.deserialize(text, type);
61        }
62
63}
Note: See TracBrowser for help on using the repository browser.