Last change
on this file since 77 was
77,
checked in by psniegowski, 11 years ago
|
Add new java codebase.
|
File size:
772 bytes
|
Line | |
---|
1 | package com.framsticks.params.types; |
---|
2 | |
---|
3 | import com.framsticks.params.CastFailure; |
---|
4 | import com.framsticks.util.Numbers; |
---|
5 | |
---|
6 | /** |
---|
7 | * @author Piotr Sniegowski |
---|
8 | */ |
---|
9 | public class FloatParam extends ValueParam { |
---|
10 | @Override |
---|
11 | public boolean isNumeric() { |
---|
12 | return true; |
---|
13 | } |
---|
14 | @Override |
---|
15 | public Class getStorageType() { |
---|
16 | return Double.class; |
---|
17 | } |
---|
18 | |
---|
19 | @Override |
---|
20 | public Object reassign(Object newValue, Object oldValue) throws CastFailure { |
---|
21 | if (newValue instanceof String) { |
---|
22 | Double v = Numbers.parse((String)newValue, Double.class); |
---|
23 | if (v != null) { |
---|
24 | return v; |
---|
25 | } |
---|
26 | throw new CastFailure(); |
---|
27 | } |
---|
28 | return super.reassign(newValue, oldValue); |
---|
29 | } |
---|
30 | |
---|
31 | @Override |
---|
32 | public String getType() { |
---|
33 | return "f"; |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.