Unfamiliar Syntax

This is called a type cast. Apex has what is called a strict, static typing discipline, which means that all variables and values have a type, and that type is declared for variables at the time of compilation of the code.

Type casting declares for the Apex compiler what type of value you expect to get back from a generic function, like JSON.deserializeUntyped(), or in some cases converts from one type to another.

Here's an example of the conversion aspect of a type cast. You cannot do

Id a = SOME_VALUE;

if (a.startsWith('006')) {

because Id has no startsWith method. Id can be casted to String, though, which does:

Id a = SOME_VALUE;

if (((String)a).startsWith('006')) {

Not all types of value can be casted to one another, however.

The cases you cite are all instances, not of conversion, but the case where the data type isn't known to the compiler. These values are of type Object because they're coming back from a generic JSON deserialization routine, which doesn't know what type of data it's deserializing beforehand. Using the type cast allows you to supply this information to the compiler so that you can use and manipulate these values.


To add to David's answer, the casts in this case are following the pattern of the expected JSON structure and how JSON.deserializeUntyped converts from JSON to Apex types. It looks like the JSON has this structure:

[
    {"replacement": "...", "name": "...", ...},
    {...},
    {...}
]

A JSON array (the [ ]) is converted to an Apex list and a JSON object (the { }) is converted to an Apex map. The casts tell the compiler to expect these types.