com.googlecode.objectify.condition
Class IfDefault
java.lang.Object
com.googlecode.objectify.condition.ValueIf<java.lang.Object>
com.googlecode.objectify.condition.IfDefault
- All Implemented Interfaces:
- If<java.lang.Object,java.lang.Object>
public class IfDefault
- extends ValueIf<java.lang.Object>
This condition tests against the default value of the field that it
is placed upon, whatever that default may be. If you
initialize the field with a value, this condition will use that value
as the comparison. For example, if you have a class like this:
public class MyEntity {
@Id Long id;
@NotSaved(IfDefault.class) String foo = "defaultFoo";
}
The foo
field will be left unsaved when it has the value "defaultFoo".
Specifically, this conditional constructs an instance of your entity class
using the default (no-arg) constructor and stores the default field value for
later comparison. Note that if you initialize the field in your default constructor,
this counts!
- Author:
- Jeff Schnitzer
Constructor Summary |
IfDefault(java.lang.Class<?> clazz,
java.lang.reflect.Field field)
|
Method Summary |
boolean |
matches(java.lang.Object value)
Override this method to test a field value for your condition. |
Methods inherited from class com.googlecode.objectify.condition.ValueIf |
matches |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IfDefault
public IfDefault(java.lang.Class<?> clazz,
java.lang.reflect.Field field)
matches
public boolean matches(java.lang.Object value)
- Description copied from class:
ValueIf
- Override this method to test a field value for your condition.
For example, for a class IfNull, return true if the value is null.
- Specified by:
matches
in class ValueIf<java.lang.Object>
Copyright © 2011 Jeff Schnitzer and a gang of pirates. All Rights Reserved. Build version: 3.1