Returns the value of the field referenced by the extractor from from the record as an Option.
Returns the value of the field referenced by the extractor from
from the record as an Option. The value may be None if this
extractor does not reference a field in this record.
The record from which to extract the value.
The value referenced from the record or None.
A FieldExtractor may be used to extract data from a Record. It may be used directly via the extractFrom method, or more commonly may be used as an operand to a Record, like
rec(fieldExtractor).Extractors are meant to be more than a simple index into a record. Rather, they can retrieve any data based on a record, based on that record's template and values. Common uses of extractors are to extract data from a particular field regardless of the actual template being used, or to generate a computed value based on fields in a record, such as returning a string value for a field that is encoded as an integer.
The type parameter
Tis a convenience feature. Implementations of FieldExtractor normally have to userec(i)under the hood, which returnsAny. As such, a cast will be made at some point, and aClassCastExceptionmay be thrown if care is not taken. It is suggested that implementers of objects that implementFieldExtractorshould include a constructor that takes the class type as an argument, and do type checking based on the record field type in order to throw an error during extractor construction rather than during use.the type the extractor should return
Record