Package org.faktorips.datatype
Class ValueClassNameDatatype
java.lang.Object
org.faktorips.datatype.AbstractDatatype
org.faktorips.datatype.ValueClassNameDatatype
- All Implemented Interfaces:
Comparable<Datatype>,Datatype,ValueDatatype
- Direct Known Subclasses:
BigDecimalDatatype,BooleanDatatype,CurrencyDatatype,DateDatatype,DecimalDatatype,DoubleDatatype,GregorianCalendarDatatype,IntegerDatatype,LocalDateDatatype,LocalDateTimeDatatype,LocalTimeDatatype,LongDatatype,MoneyDatatype,MonthDayDatatype,StringDatatype,ValueClassDatatype
A datatype that represents a Java class representing a value, for example
java.lang.String. The class name is held as a String.- Author:
- Jan Ortmann
-
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanareValuesEqual(String valueA, String valueB) Returnstrueif both given strings represent the same value defined by this datatype.intCompares the values created from the two given strings.Returns the datatype's default value.getName()Returns the datatype's name.Returns the datatype's qualified name.abstract ObjectThis 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 the datatype has a special instance representingnull, otherwisefalse.booleanReturnstrueif this datatype is an abstract datatype in means of the object oriented paradigm.final booleanReturnstrueif this is an immutable datatype,falseotherwise.booleanReturnstrueif this is a mutable datatype,falseif it is an immutable datatype.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.booleanReturnstrueif this datatype represents one of Java's primitive types.booleanReturnstrueif this datatype represents values.valueToString(Object value) Returns the string representation of the given value.Methods inherited from class org.faktorips.datatype.AbstractDatatype
checkReadyToUse, compareTo, equals, hashCode, isEnum, isVoid, matchDatatype, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.faktorips.datatype.ValueDatatype
checkReadyToUse, getNullObjectId, supportsCompare
-
Constructor Details
-
ValueClassNameDatatype
-
-
Method Details
-
getName
Description copied from interface:DatatypeReturns the datatype's name. -
getQualifiedName
Description copied from interface:DatatypeReturns the datatype's qualified name.The qualified name identifies the datatype.
- Specified by:
getQualifiedNamein interfaceDatatype
-
isPrimitive
public boolean isPrimitive()Description copied from interface:DatatypeReturnstrueif this datatype represents one of Java's primitive types.- Specified by:
isPrimitivein interfaceDatatype
-
isAbstract
public boolean isAbstract()Description copied from interface:DatatypeReturnstrueif this datatype is an abstract datatype in means of the object oriented paradigm.- Specified by:
isAbstractin interfaceDatatype
-
isMutable
public boolean isMutable()Description copied from interface:ValueDatatypeReturnstrueif this is a mutable datatype,falseif it is an immutable datatype.- Specified by:
isMutablein interfaceValueDatatype- Returns:
- whether this is a mutable datatype
-
isImmutable
public final boolean isImmutable()Description copied from interface:ValueDatatypeReturnstrueif this is an immutable datatype,falseotherwise.- Specified by:
isImmutablein interfaceValueDatatype- Returns:
- whether this is an immutable datatype
-
isValueDatatype
public boolean isValueDatatype()Description copied from interface:DatatypeReturnstrueif this datatype represents values.If the method returns
true, the datatype can be safely casted toValueDatatype.- Specified by:
isValueDatatypein interfaceDatatype
-
getDefaultValue
Description copied from interface:ValueDatatypeReturns 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.- Specified by:
getDefaultValuein interfaceValueDatatype- See Also:
-
getWrapperType
Description copied from interface:ValueDatatypeIf this datatype represents a primitive type, this method returns the datatype that represents the wrapper class. Returnsnullif this datatype does not represent a primitive.- Specified by:
getWrapperTypein interfaceValueDatatype
-
valueToString
Returns the string representation of the given value. The String value returned by this method must be parsable by thegetValue(String)method.- Specified by:
valueToStringin interfaceValueDatatype- Parameters:
value- a value of this datatype- Returns:
- the value's string representation
- See Also:
-
isNull
Description copied from interface:ValueDatatypeReturnstrueif the given string isnullor the representation of the null object (if the datatype value class makes use of the null object pattern.) Returnsfalseotherwise.- Specified by:
isNullin interfaceValueDatatype- See Also:
-
NullObject
-
isParsable
Description copied from interface:ValueDatatypeReturnstrueif the given string can be parsed to a value of this datatype. Returnsfalseotherwise.- Specified by:
isParsablein interfaceValueDatatype
-
hasNullObject
public boolean hasNullObject()Description copied from interface:DatatypeReturnstrueif the datatype has a special instance representingnull, otherwisefalse. The design pattern is called the null-object pattern.- Specified by:
hasNullObjectin interfaceDatatype- Overrides:
hasNullObjectin classAbstractDatatype- See Also:
-
NullObject
-
areValuesEqual
Description copied from interface:ValueDatatypeReturnstrueif 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.- Specified by:
areValuesEqualin interfaceValueDatatype- 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.
-
compare
Description copied from interface:ValueDatatypeCompares the values created from the two given strings.- Specified by:
comparein interfaceValueDatatype- 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.
- 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.- Specified by:
getValuein interfaceValueDatatype- Parameters:
value- string representation of the value- Returns:
- The value as instance of the class this datatype represents.
- See Also:
-