de.unikassel.android.sdcframework.preferences
Class SinglePreferenceImpl<T>

Package class diagram package SinglePreferenceImpl
java.lang.Object
  extended by de.unikassel.android.sdcframework.preferences.SinglePreferenceImpl<T>
Type Parameters:
T - the type of the preference value
All Implemented Interfaces:
SinglePreference<T>
Direct Known Subclasses:
BooleanPreference, IntegerPreference, LongPreference, PriorityLevelPreference, StringPreference

public abstract class SinglePreferenceImpl<T>
extends Object
implements SinglePreference<T>

Generic abstract base class for a single preference type.

The key for the Android shared preferences will be constructed from the keyPrefix and keySuffix values provided in the constructor call.


Field Summary
private  T defaultValue
          Default preference value
private  String key
          The key value for the Android preferences
 
Constructor Summary
  SinglePreferenceImpl(String keyPrefix, String keySuffix, T defaultValue)
          Constructor
protected SinglePreferenceImpl(String key, T defaultValue)
          Constructor
 
Method Summary
 T getDefault()
          Getter for the default value
 String getKey()
          Getter for the preference key
 void setDefault(T defaultValue)
          Setter for the default value
 boolean testForKey(String key)
          Method to test for a preferences key support
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.unikassel.android.sdcframework.preferences.facade.SinglePreference
getConfiguration
 

Field Detail

defaultValue

private T defaultValue
Default preference value


key

private final String key
The key value for the Android preferences

Constructor Detail

SinglePreferenceImpl

protected SinglePreferenceImpl(String key,
                               T defaultValue)
Constructor

Parameters:
key - the key value
defaultValue - the default value

SinglePreferenceImpl

public SinglePreferenceImpl(String keyPrefix,
                            String keySuffix,
                            T defaultValue)
Constructor

Parameters:
keyPrefix - the key prefix
keySuffix - the key suffix
defaultValue - the default value
Method Detail

getKey

public final String getKey()
Description copied from interface: SinglePreference
Getter for the preference key

Specified by:
getKey in interface SinglePreference<T>
Returns:
the preference key

getDefault

public final T getDefault()
Description copied from interface: SinglePreference
Getter for the default value

Specified by:
getDefault in interface SinglePreference<T>
Returns:
the default value

setDefault

public final void setDefault(T defaultValue)
Description copied from interface: SinglePreference
Setter for the default value

Specified by:
setDefault in interface SinglePreference<T>
Parameters:
defaultValue - the default value to set

testForKey

public boolean testForKey(String key)
Description copied from interface: SinglePreference
Method to test for a preferences key support

Specified by:
testForKey in interface SinglePreference<T>
Parameters:
key - the key to test for
Returns:
true if this key is supported, false otherwise