Class DefaultInitializedConstraint
- java.lang.Object
-
- science.aist.gtf.verification.syntactic.constraint.impl.DefaultInitializedConstraint
-
- All Implemented Interfaces:
BiFunction<Object,Field,ConstraintError>
,Constraint<Object>
public class DefaultInitializedConstraint extends Object implements Constraint<Object>
Constraint which checks if an object is default initialized
- Since:
- 1.0
- Author:
- Christoph Praschl
-
-
Constructor Summary
Constructors Constructor Description DefaultInitializedConstraint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
addUserdefinedDefaultValue(Class<?> clazz, String fieldName, T defaultValue)
Method for adding user defined default values for specific fields of a given class<T> void
addUserdefinedDefaultValue(Field field, T defaultValue)
Method for adding user defined default values for specific fields of a given classConstraintError
apply(Object o, Field f)
<T> T
getDefaultValueForField(Field field)
Get default value of given clazzClass<Object>
getType()
boolean
isBreakingConstraint()
void
setUserdefinedDefaultValues(Map<Class<?>,Map<String,Object>> userdefinedDefaultValues)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
getDefaultValueForField
public <T> T getDefaultValueForField(Field field)
Get default value of given clazz- Type Parameters:
T
- type of clazz- Parameters:
field
- field to be checked if there is a user defined default value- Returns:
- default value of field; if no user defined value was set returns default value of clazz
-
addUserdefinedDefaultValue
public <T> void addUserdefinedDefaultValue(Field field, T defaultValue)
Method for adding user defined default values for specific fields of a given class- Type Parameters:
T
- Generic type of the default value- Parameters:
field
- field for which the default value should be defineddefaultValue
- the new default value
-
addUserdefinedDefaultValue
public <T> void addUserdefinedDefaultValue(Class<?> clazz, String fieldName, T defaultValue)
Method for adding user defined default values for specific fields of a given class- Type Parameters:
T
- Generic type of the default value- Parameters:
clazz
- clazz containing the fieldfieldName
- name of the field for which the default value should be defineddefaultValue
- the new default value
-
setUserdefinedDefaultValues
public void setUserdefinedDefaultValues(Map<Class<?>,Map<String,Object>> userdefinedDefaultValues)
- Parameters:
userdefinedDefaultValues
- sets the collection ofuserdefinedDefaultValues
-
apply
public ConstraintError apply(Object o, Field f)
- Specified by:
apply
in interfaceBiFunction<Object,Field,ConstraintError>
-
getType
public Class<Object> getType()
- Specified by:
getType
in interfaceConstraint<Object>
- Returns:
- method which returns the type for which the constraint is applied
-
isBreakingConstraint
public boolean isBreakingConstraint()
- Specified by:
isBreakingConstraint
in interfaceConstraint<Object>
- Returns:
- a flag if constraint is breaking and if violated no further constraints should be checked (e.q. because of a NullPointer)
-
-