Foundations Apex API Developer Reference

fferpcore.DataType

global inherited sharing class DataType implements ObjectIO.SerializableObject

Representation of a scalar data type.

Methods

forDescribedField

global static fferpcore.DataType forDescribedField(DescribeFieldResult describedField)

Input Parameters

Name Type Description
describedField DescribeFieldResult A described SObjectField.

Return Value

The corresponding DataType for the given DescribeFieldResult.

forDisplayType

global static fferpcore.DataType forDisplayType(DisplayType displayType, Integer length, Integer scale)

Input Parameters

Name Type Description
displayType DisplayType The DisplayType corresponding to the DataType.
length Integer The maximum length of the type.
scale Integer The accuracy of the type.

Return Value

The corresponding DataType for the given DisplayType.

DataType

global DataType(Schema.DisplayType type, Integer length, Integer scale)

This constructor creates a class which is a representation of a scalar data type. This holds information about the type, length and scale of the data type.

Input Parameters

Name Type Description
type Schema.DisplayType The type to associate the data type to.
length Integer The maximum length of the type e.g. number of characters in a string.
scale Integer The accuracy of the type e.g. number of decimals allowed.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.DataType example = new fferpcore.DataType(Schema.DisplayType.Double, 10, 5);

System.assertEquals('DOUBLE', example.getName());
System.assertEquals(10, example.getLength());
System.assertEquals(5, example.getScale());
System.assertEquals('DOUBLE(10,5)', example.toString());

coerceToType

global Object coerceToType(Object data)

Convert the given data to suitable data for the DataType. The input may be an Object, for example from JSON.deserializeUntyped. It may be a String from user configuration.

Input Parameters

Name Type Description
data Object Value to be converted.

Return Value

A new value suitable for the DataType.

getName

global String getName()

This method returns the name of the scalar data type this is associated with. See Salesforce's DisplayType Enum.

Return Value

This service returns a string object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.DataType example = new fferpcore.DataType(Schema.DisplayType.Double, 10, 5);

System.assertEquals('DOUBLE', example.getName());
System.assertEquals(10, example.getLength());
System.assertEquals(5, example.getScale());
System.assertEquals('DOUBLE(10,5)', example.toString());

getLength

global Integer getLength()

This method returns the length of the scalar data type this it is associated with. If the data type has a length, for example String or Double, the length value is returned, otherwise NULL is returned.

Return Value

This service returns an Integer object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.DataType example = new fferpcore.DataType(Schema.DisplayType.Double, 10, 5);

System.assertEquals('DOUBLE', example.getName());
System.assertEquals(10, example.getLength());
System.assertEquals(5, example.getScale());
System.assertEquals('DOUBLE(10,5)', example.toString());

getScale

global Integer getScale()

This method returns the scale of the scalar data type this it is associated with. If the data type has a scale, for example a Double, the scale value is returned, otherwise NULL is returned.

Return Value

This service returns an Integer object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.DataType example = new fferpcore.DataType(Schema.DisplayType.Double, 10, 5);

System.assertEquals('DOUBLE', example.getName());
System.assertEquals(10, example.getLength());
System.assertEquals(5, example.getScale());
System.assertEquals('DOUBLE(10,5)', example.toString());

toString

global override String toString()

Display representation. Examples Boolean, String(64), Double(18,2)

Return Value

This service returns a string object.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

fferpcore.DataType example = new fferpcore.DataType(Schema.DisplayType.Double, 10, 5);

System.assertEquals('DOUBLE', example.getName());
System.assertEquals(10, example.getLength());
System.assertEquals(5, example.getScale());
System.assertEquals('DOUBLE(10,5)', example.toString());

equals

global Boolean equals(Object other)

hashCode

global Integer hashCode()

© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.