1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hivegui.application; |
16 | |
17 | import java.util.HashMap; |
18 | import java.util.Map; |
19 | |
20 | import org.jdesktop.application.AbstractBean; |
21 | |
22 | public abstract class AbstractPropertyBean extends AbstractBean |
23 | { |
24 | @SuppressWarnings("unchecked") |
25 | protected<T> void setProperty(String name, T value) |
26 | { |
27 | T old = (T) _properties.put(name, value); |
28 | firePropertyChange(name, old, value); |
29 | } |
30 | |
31 | @SuppressWarnings("unchecked") |
32 | protected<T> T getProperty(String name) |
33 | { |
34 | return (T) _properties.get(name); |
35 | } |
36 | |
37 | protected boolean getBooleanProperty(String name) |
38 | { |
39 | return (Boolean) getProperty(name); |
40 | } |
41 | |
42 | protected int getIntProperty(String name) |
43 | { |
44 | return (Integer) getProperty(name); |
45 | } |
46 | |
47 | protected long getLongProperty(String name) |
48 | { |
49 | return (Long) getProperty(name); |
50 | } |
51 | |
52 | protected float getFloatProperty(String name) |
53 | { |
54 | return (Float) getProperty(name); |
55 | } |
56 | |
57 | protected double getDoubleProperty(String name) |
58 | { |
59 | return (Double) getProperty(name); |
60 | } |
61 | |
62 | final protected Map<String, Object> _properties = new HashMap<String, Object>(); |
63 | } |