public class Feature extends AbstractSetting<java.lang.Boolean>
Feature
represents optional feature in the code.
Normally this should be encapsulated as a singleton constant field so we can
locate them by reflection and generate on-line documentation.
Each Feature
object defines a name for the feature a default setting and descriptive documentation.
Some legacy features may be generated dynamically so the same feature may be constructed multiple times but Feature
s with
the same name should be identical.
Feature
s can be turned on and off using configuration parameters
e.g. service.feature.feature-name=true
The results are also cached in the AppContext
as the same Feature
may be queried a large number of times in the same request.
Constructor and Description |
---|
Feature(java.lang.String name) |
Feature(java.lang.String name,
boolean def,
java.lang.String description) |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkDynamicFeature(AppContext conn,
java.lang.String name,
boolean def)
checks a feature that is only defined by name (ie the name is generated dynamically)
|
static boolean |
checkFeature(AppContext conn,
java.lang.String name)
Test a feature by name.
|
java.lang.Boolean |
find(java.lang.String o)
Find the required object.
|
protected boolean |
getConfigValue(AppContext conn) |
java.lang.Boolean |
getCurrent(AppContext conn)
get the current value of the setting
|
java.lang.String |
getIndex(java.lang.Boolean value)
Get the underlying data representation corresponding to the value
|
ItemInput<java.lang.String,java.lang.Boolean> |
getInput(AppContext conn)
and
Input to select the setting |
protected java.lang.String |
getTag() |
java.lang.Class<java.lang.Boolean> |
getTarget()
Get the type of the returned object as far as it is known.
|
java.lang.String |
getText(java.lang.Boolean b) |
boolean |
isDef() |
boolean |
isEnabled(AppContext conn) |
boolean |
isEnabled(java.util.Properties prop)
query a property bundle not the
AppContext . |
static void |
setTempFeature(AppContext conn,
Feature f,
boolean val) |
equals, findFeatureByName, getDefault, getDescription, getFeatureTable, getKnownFeatures, getName, hashCode, toString
public Feature(java.lang.String name, boolean def, java.lang.String description)
public Feature(java.lang.String name)
public final boolean isDef()
public boolean isEnabled(AppContext conn)
protected boolean getConfigValue(AppContext conn)
protected java.lang.String getTag()
public boolean isEnabled(java.util.Properties prop)
AppContext
. The result is NOT cached.prop
- public static boolean checkFeature(AppContext conn, java.lang.String name)
conn
- name
- public static boolean checkDynamicFeature(AppContext conn, java.lang.String name, boolean def)
conn
- name
- public static void setTempFeature(AppContext conn, Feature f, boolean val)
public ItemInput<java.lang.String,java.lang.Boolean> getInput(AppContext conn)
Setting
Input
to select the settingpublic java.lang.Boolean getCurrent(AppContext conn)
Setting
conn
- AppContextpublic java.lang.String getText(java.lang.Boolean b)
getText
in class AbstractSetting<java.lang.Boolean>
public java.lang.Boolean find(java.lang.String o)
TypeConverter
o
- Value of the database fieldpublic java.lang.String getIndex(java.lang.Boolean value)
TypeConverter
public java.lang.Class<java.lang.Boolean> getTarget()
Targetted