*
* @param configuration lets help the {@link org.apache.tapestry5.ioc.services.TypeCoercer} service
*/
public static void contributeTypeCoercer(Configuration<CoercionTuple> configuration)
{
configuration.add(new CoercionTuple(String.class, WriteConcern.class,
new Coercion<String, WriteConcern>() {
public WriteConcern coerce(String input)
{
if (input.equalsIgnoreCase("FSYNC_SAFE"))
{
return WriteConcern.FSYNC_SAFE;
}
else if (input.equalsIgnoreCase("JOURNAL_SAFE"))
{
return WriteConcern.JOURNAL_SAFE;
}
else if (input.equalsIgnoreCase("MAJORITY"))
{
return WriteConcern.MAJORITY;
}
else if (input.equalsIgnoreCase("NONE"))
{
return WriteConcern.NONE;
}
else if (input.equalsIgnoreCase("REPLICAS_SAFE"))
{
return WriteConcern.REPLICAS_SAFE;
}
else if (input.equalsIgnoreCase("SAFE"))
{
return WriteConcern.SAFE;
}
else if (input.equalsIgnoreCase("NORMAL"))
{
return WriteConcern.NORMAL;
}
else // WriteConcern.ACKNOWLEDGED IS OUR DEFAULT
{
return WriteConcern.ACKNOWLEDGED;
}
}
}
));
configuration.add(new CoercionTuple(String.class, ReadPreference.class, new Coercion<String, ReadPreference>() {
public ReadPreference coerce(String input)
{
if (input.equalsIgnoreCase("SECONDARY"))
{
return ReadPreference.secondary();