Interface RecordAccessor

All Known Subinterfaces: Record, RecordBuilder


public interface RecordAccessor

Allows to access Salesforce record data.

See Also: Record, RecordBuilder

Modifier and TypeMethodDescription
java.util.Optional<java.math.BigDecimal>getBigDecimalField(java.lang.String name)Returns the value of a field as a BigDecimal.
java.util.Optional<java.math.BigInteger>getBigIntegerField(java.lang.String name)Returns the value of a field as a BigInteger which may involve rounding.
java.util.Optional<java.nio.ByteBuffer>getBinaryField(java.lang.String name)Returns the value of a binary field as a ByteBuffer.
java.util.Optional<java.lang.Boolean>getBooleanField(java.lang.String name)Returns the value of a field as a Boolean.
java.util.Optional<java.lang.Byte>getByteField(java.lang.String name)Returns the value of a field as a Byte, which may involve rounding or truncation.
java.util.Optional<java.lang.Double>getDoubleField(java.lang.String name)Returns the value of a field as a Double, which may involve rounding or truncation.
java.util.Set<java.lang.String>getFieldNames()Returns the names of all fields present in this record.
java.util.Optional<java.lang.Float>getFloatField(java.lang.String name)Returns the value of a field as a Float, which may involve rounding or truncation.
java.util.Optional<java.lang.Integer>getIntField(java.lang.String name)Returns the value of a field as an Integer, which may involve rounding or truncation.
java.util.Optional<java.lang.Long>getLongField(java.lang.String name)Returns the value of a field as a Long, which may involve rounding or truncation.
java.util.Optional<Record>getRecordField(java.lang.String name)Returns the value of the record field as a Record or empty Optional if the field is not present or null.
java.util.Optional<java.lang.Short>getShortField(java.lang.String name)Returns the value of a field as a Short, which may involve rounding or truncation.
java.util.Optional<java.lang.String>getStringField(java.lang.String name)Returns the value of a field as a String.
java.lang.StringgetType()Returns the type of this record.
booleanhasField (java.lang.String name)Returns if this record has a field with the given name.
booleanisNullField(java.lang.String name)Returns if this record has a field with the given name that has null as its value.

@Nonnull java.lang.String getType()

Returns the type of this record.

Returns: The type of this record.

Returns the type of this record.

@Nonnull java.util.Set<java.lang.String> getFieldNames()

Returns the names of all fields present in this record.

This includes fields that have null as their value.

Returns: The names of all fields present in this record.

@Nonnull java.util.Set<java.lang.String> getFieldNames()

boolean hasField​(java.lang.String name)

Returns if this record has a field with the given name. The field name is compared case-insensitively.

This includes fields that have null as their value.

Parameters: name - The name of the field to check. Returns: If this record has a field with the given name.

Returns: The names of all fields present in this record.

boolean isNullField​(java.lang.String name)

Returns if this record has a field with the given name that has null as its value. The field name is compared case-insensitively.

If there is no field with the given name, false is returned.

Parameters: name - The name of the field to check. Returns: If this record has a field with the given name that has null as its value.

Returns if this record has a field with the given name. The field name is compared case-insensitively.

@Nonnull java.util.Optional<java.lang.String> getStringField​(java.lang.String name)

Returns the value of a field as a String. The field name is compared case-insensitively.

Field values that are not Strings will be automatically converted to Strings. For example, if the field contains the number 42, this method will return an Optional that contains the String "42".

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a String or empty Optional if the field is not present or null.

@Nonnull java.util.Optional<java.lang.Boolean> getBooleanField​(java.lang.String name)

Returns the value of a field as a Boolean. The field name is compared case-insensitively.

If the field is not a boolean, its value is converted to a String first, and then parsed with Boolean.parseBoolean(String). Effectively, this means that any non-boolean value except the String "true" (compared case-insensitive) will result in false being returned by this method.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a Boolean or empty Optional if the field is not present or null.

@Nonnull java.util.Optional<java.lang.Byte> getByteField​(java.lang.String name)

Returns the value of a field as a Byte, which may involve rounding or truncation. The field name is compared case-insensitively.

If field's value is not a number, this method will try to parse it as one. This allows Strings that represent numbers to be interpreted as numbers. If the value cannot be parsed as a number, a NumberFormatException is thrown.

If the (if necessary, parsed) value cannot be directly represented as a Byte (i.e. the value is too large or contains decimals), it will be converted to a Byte which may involve rounding or truncation of the value.

The conversion is analogous to a narrowing primitive conversion or a widening primitive conversion as defined in The Java® Language Specification for converting between primitive types. Therefore, conversions may lose information about the overall magnitude of a numeric value, may lose precision, and may even return a result of a different sign.

If full control over the conversion is required, getBigDecimalField(String) can be used. BigDecimal offers an extensive suite of methods to convert from a BigDecimal to primitive number types.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a Byte or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as a Byte value. See Also:

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a String or empty Optional if the field is not present or null.

@Nonnull java.util.Optional<java.lang.Short> getShortField​(java.lang.String name)

Returns the value of a field as a Short, which may involve rounding or truncation. The field name is compared case-insensitively.

If field's value is not a number, this method will try to parse it as one. This allows Strings that represent numbers to be interpreted as numbers. If the value cannot be parsed as a number, a NumberFormatException is thrown.

If the (if necessary, parsed) value cannot be directly represented as a Short (i.e. the value is too large or contains decimals), it will be converted to a Short which may involve rounding or truncation of the value.

The conversion is analogous to a narrowing primitive conversion or a widening primitive conversion as defined in The Java® Language Specification for converting between primitive types. Therefore, conversions may lose information about the overall magnitude of a numeric value, may lose precision, and may even return a result of a different sign.

If full control over the conversion is required, getBigDecimalField(String) can be used. BigDecimal offers an extensive suite of methods to convert from a BigDecimal to primitive number types.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a Short or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as a Short value. See Also:

@Nonnull java.util.Optional<java.lang.Integer> getIntField​(java.lang.String name)

Returns the value of a field as an Integer, which may involve rounding or truncation. The field name is compared case-insensitively.

If field's value is not a number, this method will try to parse it as one. This allows Strings that represent numbers to be interpreted as numbers. If the value cannot be parsed as a number, a NumberFormatException is thrown.

If the (if necessary, parsed) value cannot be directly represented as an Integer (i.e. the value is too large or contains decimals), it will be converted to an Integer which may involve rounding or truncation of the value.

The conversion is analogous to a narrowing primitive conversion or a widening primitive conversion as defined in The Java® Language Specification for converting between primitive types. Therefore, conversions may lose information about the overall magnitude of a numeric value, may lose precision, and may even return a result of a different sign.

If full control over the conversion is required, getBigDecimalField(String) can be used. BigDecimal offers an extensive suite of methods to convert from a BigDecimal to primitive number types.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as an Integer or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as an Integer value. See also:

@Nonnull java.util.Optional<java.lang.Long> getLongField​(java.lang.String name)

Returns the value of a field as a Long, which may involve rounding or truncation. The field name is compared case-insensitively.

If field's value is not a number, this method will try to parse it as one. This allows Strings that represent numbers to be interpreted as numbers. If the value cannot be parsed as a number, a NumberFormatException is thrown.

If the (if necessary, parsed) value cannot be directly represented as a Long (i.e. the value is too large or contains decimals), it will be converted to a Long which may involve rounding or truncation of the value.

The conversion is analogous to a narrowing primitive conversion or a widening primitive conversion as defined in The Java® Language Specification for converting between primitive types. Therefore, conversions may lose information about the overall magnitude of a numeric value, may lose precision, and may even return a result of a different sign.

If full control over the conversion is required, getBigDecimalField(String) can be used. BigDecimal offers an extensive suite of methods to convert from a BigDecimal to primitive number types.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a Long or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as a Long value. See Also:

@Nonnull java.util.Optional<java.lang.Float> getFloatField​(java.lang.String name)

Returns the value of a field as a Float, which may involve rounding or truncation. The field name is compared case-insensitively.

If field's value is not a number, this method will try to parse it as one. This allows Strings that represent numbers to be interpreted as numbers. If the value cannot be parsed as a number, a NumberFormatException is thrown.

If the (if necessary, parsed) value cannot be directly represented as a Float (i.e. the value is too large or contains decimals), it will be converted to a Float which may involve rounding or truncation of the value.

The conversion is analogous to a narrowing primitive conversion or a widening primitive conversion as defined in The Java® Language Specification for converting between primitive types. Therefore, conversions may lose information about the overall magnitude of a numeric value, may lose precision, and may even return a result of a different sign.

If full control over the conversion is required, getBigDecimalField(String) can be used. BigDecimal offers an extensive suite of methods to convert from a BigDecimal to primitive number types.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a Float or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as a Float value. See Also:

@Nonnull java.util.Optional<java.lang.Double> getDoubleField​(java.lang.String name)

Returns the value of a field as a Double, which may involve rounding or truncation. The field name is compared case-insensitively.

If field's value is not a number, this method will try to parse it as one. This allows Strings that represent numbers to be interpreted as numbers. If the value cannot be parsed as a number, a NumberFormatException is thrown.

If the (if necessary, parsed) value cannot be directly represented as a Double (i.e. the value is too large or contains decimals), it will be converted to a Double which may involve rounding or truncation of the value.

The conversion is analogous to a narrowing primitive conversion or a widening primitive conversion as defined in The Java® Language Specification for converting between primitive types. Therefore, conversions may lose information about the overall magnitude of a numeric value, may lose precision, and may even return a result of a different sign.

If full control over the conversion is required, getBigDecimalField(String) can be used. BigDecimal offers an extensive suite of methods to convert from a BigDecimal to primitive number types.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a Double or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as a Double value. See Also:

@Nonnull java.util.Optional<java.math.BigInteger> getBigIntegerField​(java.lang.String name)

Returns the value of a field as a BigInteger which may involve rounding. The field name is compared case-insensitively.

If field's value is not a number, this method will try to parse it as one. If that process fails, a NumberFormatException is thrown.

If the (if necessary, parsed) value cannot be directly represented as a BigInteger (i.e. the value contains decimals), it will be converted to a BigInteger which may involve rounding. Use getBigDecimalField(String) support for decimals is required.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a BigInteger or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as a BigInteger value. See Also: getBigDecimalField(String)

@Nonnull java.util.Optional<java.math.BigDecimal> getBigDecimalField​(java.lang.String name)

Returns the value of a field as a BigDecimal. The field name is compared case-insensitively.

If the field's value is not a number, this method will try to parse it as one. If that process fails, or the number cannot be represented as a BigDecimal, a NumberFormatException is thrown.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the field as a BigDecimal or empty Optional if the field is not present or null. Throws: java.lang.NumberFormatException If the value could not be parsed as a BigDecimal value.

@Nonnull Optional<java.nio.ByteBuffer> getBinaryField​(java.lang.String name)

Returns the value of a binary field as a ByteBuffer. The field name is compared case-insensitively.

Only field values that are binary data are converted to a ByteBuffer. If you use this method on a non-binary field then a FieldConversionException is thrown.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the binary field as a ByteBuffer or empty Optional if the field isn't present or is null. Throws:FieldConversionException if the value isn't binary data.

@Nonnull Optional<Record> getRecordField​(java.lang.String name)

Returns the value of a record field as a Record. The field name is compared case-insensitively.

Only field values that are record data are converted to a Record. If you use this method on a non-record field then a FieldConversionException is thrown.

Parameters: name - The name of the field to obtain the value from. Returns: The value of the record field as a Record or empty Optional if the field isn't present or is null. Throws: FieldConversionException if the value isn't record data.