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