litesoft
@ 804
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt package org.litesoft.GWT.client.view; import org.litesoft.GWT.client.*; import org.litesoft.core.typeutils.*; public class Property<T> { private final Properties mProperties; private final String mName; private final T mDefault; public Property( Properties pProperties, String pName ) { this( pProperties, pName, null ); } /** * @param pProperties non-null * @param pName non-null * @param pDefault optional */ public Property( Properties pProperties, String pName, T pDefault ) { Objects.assertNotNull( "pProperties", pProperties ); UtilsGwt.assertNotNullNotEmpty( "pName", pName ); mProperties = pProperties; mName = pName; mDefault = pDefault; } public String getName() { return mName; } @SuppressWarnings("unchecked") public T get() { T value = (T) mProperties.get( getName() ); return (value != null) ? value : mDefault; } public T getDefault() { return mDefault; } public void set( T pValue ) { mProperties.set( mName, pValue ); } } |