org.deri.iris.builtins.datatype
Class ToIntegerBuiltin
java.lang.Object
org.deri.iris.builtins.AbstractBuiltin
org.deri.iris.builtins.FunctionalBuiltin
org.deri.iris.builtins.datatype.ConversionBuiltin
org.deri.iris.builtins.datatype.ToIntegerBuiltin
- All Implemented Interfaces:
- Comparable<IAtom>, IAtom, IBuiltinAtom
public class ToIntegerBuiltin
- extends ConversionBuiltin
Represents a data type conversion function, which converts supported data
type instances to Integer instances. The following data types are supported:
- Decimal
- Double
- Float
- Integer
- String
ToIntegerBuiltin
public ToIntegerBuiltin(ITerm... terms)
- Creates a new instance of this builtin.
- Parameters:
terms - The term representing the data type instance to be
converted.
convert
protected ITerm convert(ITerm term)
- Description copied from class:
ConversionBuiltin
- Converts the given supported data type instance to the specific data type
- Specified by:
convert in class ConversionBuiltin
- Returns:
- The result of the conversion or
null if the
specified data type is not compatible.
toInteger
public static IIntegerTerm toInteger(IBooleanTerm term)
- Converts a Boolean term to an Integer term. A Boolean term representing
the value "True" is converted to an Integer term representing "1". A
Boolean term representing the value "False" is converted to an Integer
term representing "0".
- Parameters:
term - The Boolean term to be converted.
- Returns:
- A new Integer term representing the result of the conversion.
toInteger
public static IIntegerTerm toInteger(INumericTerm term)
- Converts a Numeric term to an Integer term.
- Parameters:
term - The Numeric term to be converted.
- Returns:
- A new Integer term representing the result of the conversion.
toInteger
public static IIntegerTerm toInteger(IStringTerm term)
- Converts a String term to an Integer term.
- Parameters:
term - The String term to be converted.
- Returns:
- A new Integer term representing the result of the conversion, or
null if the conversion fails.