Package org.faktorips.datatype
Interface ValueDatatype
- All Superinterfaces:
Comparable<Datatype>,Datatype
- All Known Subinterfaces:
EnumDatatype,NamedDatatype,NumericDatatype
- All Known Implementing Classes:
AbstractPrimitiveDatatype,ArrayOfValueDatatype,BigDecimalDatatype,BooleanDatatype,CurrencyDatatype,DateDatatype,DecimalDatatype,DefaultGenericEnumDatatype,DefaultGenericValueDatatype,DoubleDatatype,GenericEnumDatatype,GenericValueDatatype,GregorianCalendarAsDateDatatype,GregorianCalendarDatatype,IntegerDatatype,InternationalStringDatatype,ListOfTypeDatatype,LocalDateDatatype,LocalDateTimeDatatype,LocalTimeDatatype,LongDatatype,MoneyDatatype,MonthDayDatatype,PrimitiveBooleanDatatype,PrimitiveIntegerDatatype,PrimitiveLongDatatype,StringDatatype,ValueClassDatatype,ValueClassNameDatatype,Void
A datatype representing values (in contrast to reference objects).
-
Field Summary
Fields inherited from interface org.faktorips.datatype.Datatype
BIG_DECIMAL, BOOLEAN, DECIMAL, DOUBLE, GREGORIAN_CALENDAR, INTEGER, LONG, MONEY, PRIMITIVE_BOOLEAN, PRIMITIVE_INT, PRIMITIVE_LONG, STRING, VOID -
Method Summary
Modifier and TypeMethodDescriptionbooleanareValuesEqual(String valueA, String valueB) Returnstrueif both given strings represent the same value defined by this datatype.org.faktorips.runtime.MessageListValidates the value datatype and returns a message list containing error messages if the datatype is invalid.intCompares the values created from the two given strings.Returns the datatype's default value.default StringReturns the string representation of the special null-object, if the datatype uses one.This method parses the given string and returns the value as an instance of the class this value datatype represents.If this datatype represents a primitive type, this method returns the datatype that represents the wrapper class.booleanReturnstrueif this is an immutable datatype,falseotherwise.booleanReturnstrueif this is a mutable datatype,falseif it is an immutable datatype.default booleanReturnstrueif the given string isnullor the representation of the null object (if the datatype value class makes use of the null object pattern.)booleanisParsable(String value) Returnstrueif the given string can be parsed to a value of this datatype.booleandefault StringvalueToString(Object value) Returns the string representation of the given value compatible togetValue(String).Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.faktorips.datatype.Datatype
getName, getQualifiedName, hasNullObject, isAbstract, isEnum, isPrimitive, isValueDatatype, isVoid
-
Method Details
-
getWrapperType
ValueDatatype getWrapperType()If this datatype represents a primitive type, this method returns the datatype that represents the wrapper class. Returnsnullif this datatype does not represent a primitive. -
isParsable
Returnstrueif the given string can be parsed to a value of this datatype. Returnsfalseotherwise. -
isNull
Returnstrueif the given string isnullor the representation of the null object (if the datatype value class makes use of the null object pattern.) Returnsfalseotherwise.- See Also:
-
NullObject
-
getNullObjectId
Returns the string representation of the special null-object, if the datatype uses one.- See Also:
-
Datatype.hasNullObject()NullObject
-
isMutable
boolean isMutable()Returnstrueif this is a mutable datatype,falseif it is an immutable datatype.- Returns:
- whether this is a mutable datatype
-
isImmutable
boolean isImmutable()Returnstrueif this is an immutable datatype,falseotherwise.- Returns:
- whether this is an immutable datatype
-
getDefaultValue
String getDefaultValue()Returns the datatype's default value. For datatypes representing objects the method returnsnull. For datatypes representing Java primitives the Java default value is returned, e.g. 0 for int.- Throws:
UnsupportedOperationException- if this datatype is the DatatypeVoid.- See Also:
-
getValue
This method parses the given string and returns the value as an instance of the class this value datatype represents.Use with caution: During development time Faktor-IPS maintains all values with their string representation. This allows to change the value's datatype without the need to convert the value from one class to another (e.g. if the string representation is 42 you can change the datatype from integer to string without converting the integer object to a string object.
May throw different exceptions if the given string does not represent any value, for example a
NumberFormatExceptionwhen"twelve"is passed toPrimitiveIntegerDatatype.getValue(String).- Parameters:
value- the string representation of a value- Returns:
- the value as instance of the class this datatype represents
- See Also:
-
valueToString
Returns the string representation of the given value compatible togetValue(String).- Parameters:
value- a value of this datatype- Returns:
- the value's string representation
- See Also:
-
supportsCompare
boolean supportsCompare()- Returns:
trueif this datatype is able to compare two values.
-
compare
Compares the values created from the two given strings.- Parameters:
valueA- The value to compare to valueBvalueB- The value to compare to valueA- Returns:
- A value less than 0 if valueA is less than valueB, 0 if valueA is equal to valueB and a value greater than 0 if valueA is greater than valueB.
- Throws:
UnsupportedOperationException- if compare is not supported by this datatype.- See Also:
-
areValuesEqual
Returnstrueif both given strings represent the same value defined by this datatype. The String " 1" (a blank followed by the char '1') and "1" (just the char '1') are equal if the datatype is anInteger, but will not be equal if the datatype is aString.- Parameters:
valueA- The first parameter to comparevalueB- The second parameter to compare- Returns:
trueif the two values are equal according to the datatype, returnsfalseif they are different.- Throws:
IllegalArgumentException- if one of the parameter values doesn't exist in the value set of this datatype.
-
checkReadyToUse
org.faktorips.runtime.MessageList checkReadyToUse()Validates the value datatype and returns a message list containing error messages if the datatype is invalid. If the datatype is valid an empty list is returned.Value datatypes like the predefined datatypes (defined by the constants in this class) are always valid. However generic datatypes that implement this interface might be invalid.
-