Field

The Field class represents a property that a record may have. It is analogous to a table column, or—in Salesforce—an object field.

We refer to Fields when we are inspecting the Schema, or shape, of records for a particular table or object. You will encounter this Valence class if you are implementing the SchemaAdapter interface.

Fields are constructed using a builder pattern that uses a fluent interface to make it simple to construct Field instances with varying degrees of complexity.

You get a FieldBuilder by calling Field.create() and passing the API name of the Field you are constructing. This is the only required property, but it’s an important one. This string value is expected to match exactly to what is used on the records that will be retrieved from, and given to, your Adapter.

Simple Field Example

valence.Field firstNameField = valence.Field.create('firstName').withLabel('First Name').build();

More Complex Field Example

valence.Field startDateField = valence.Field.create('startDate')
    .withLabel('Start Date')
    .withDescription('What day this subscription was first activated')
    .withType('string')
    .withFormat('yyyy-MM-dd')
    .withExampleValue('2017-01-24')
    .build();

Properties

Data Type Class Property Builder Method Description
String name   Required. Expected to match actual record field names.
String label withLabel User-friendly label for this field.
String description withDescription Description of the field’s purpose.
String exampleValue withExampleValue An example value to help give a user context.
String defaultValue withDefaultValue The default value that will be used if this field is left blank.
String type withType The data type of the field.
String format withFormat The format of the value, if applicable.
Boolean isCreateable setCreateable True if this field can be set on record creation.
Boolean isUpdateable setUpdateable True if this field can be set on record update.
Boolean isEditable setEditable True if either isCreateable or isUpdateable have been set. Can also be set independently.