Code review comment: I feel like we need to either link to the API ref or somehow communicate the expected types for each receipt field. Sorry if you did this and I missed it

Code under review:
public static void main(final String[] args) {
        
        FormRecognizerClient client = new FormRecognizerClientBuilder()
            .credential(new AzureKeyCredential("{key}"))
            .endpoint("https:
            .buildClient();

        String receiptUrl = "https:
            + "/azure-ai-formrecognizer/src/samples/java/sample-forms/receipts/contoso-allinone.jpg";
        SyncPoller<OperationResult, List<RecognizedForm>> recognizeReceiptPoller =
            client.beginRecognizeReceiptsFromUrl(receiptUrl);

        List<RecognizedForm> receiptPageResults = recognizeReceiptPoller.getFinalResult();

        for (int i = 0; i < receiptPageResults.size(); i++) {
            RecognizedForm recognizedReceipt = receiptPageResults.get(i);
            Map<String, FormField<?>> recognizedFields = recognizedReceipt.getFields();
            System.out.printf("----------- Recognized Receipt page %d -----------%n", i);
            FormField<?> merchantNameField = recognizedFields.get("MerchantName");
            if (merchantNameField != null) {
                Object merchantNameFieldValue = merchantNameField.getValue();
                if (merchantNameFieldValue instanceof String) {
                    String merchantName = (String) merchantNameFieldValue;
                    System.out.printf("Merchant Name: %s, confidence: %.2f%n",
                        merchantName, merchantNameField.getConfidence());
                }
            }

            FormField<?> merchantAddressField = recognizedFields.get("MerchantAddress");
            if (merchantAddressField != null) {
                Object merchantAddressFieldValue = merchantAddressField.getValue();
                if (merchantAddressFieldValue instanceof String) {
                    String merchantAddress = (String) merchantAddressFieldValue;
                    System.out.printf("Merchant Address: %s, confidence: %.2f%n",
                        merchantAddress, merchantAddressField.getConfidence());
                }
            }

            FormField<?> transactionDateField = recognizedFields.get("TransactionDate");
            if (transactionDateField != null) {
                Object transactionDateFieldValue = transactionDateField.getValue();
                if (transactionDateFieldValue instanceof LocalDate) {
                    LocalDate transactionDate = (LocalDate) transactionDateFieldValue;
                    System.out.printf("Transaction Date: %s, confidence: %.2f%n",
                        transactionDate, transactionDateField.getConfidence());
                }
            }

            FormField<?> receiptItemsField = recognizedFields.get("Items");
            if (receiptItemsField != null) {
                System.out.printf("Receipt Items: %n");
                if (receiptItemsField.getValue() instanceof List) {
                    List<FormField<?>> receiptItems = (List<FormField<?>>) receiptItemsField.getValue();
                    receiptItems.forEach(receiptItem -> {
                        if (receiptItem.getValue() instanceof Map) {
                            ((Map<String, FormField<?>>) receiptItem.getValue()).forEach((key, formField) -> {
                                if ("Name".equals(key)) {
                                    if (formField.getValue() instanceof String) {
                                        String name = (String) formField.getValue();
                                        System.out.printf("Name: %s, confidence: %.2fs%n",
                                            name, formField.getConfidence());
                                    }
                                }
                                if ("Quantity".equals(key)) {
                                    if (formField.getValue() instanceof Integer) {
                                        Integer quantity = (Integer) formField.getValue();
                                        System.out.printf("Quantity: %d, confidence: %.2f%n",
                                            quantity, formField.getConfidence());
                                    }
                                }
                                if ("Price".equals(key)) {
                                    if (formField.getValue() instanceof Float) {
                                        Float price = (Float) formField.getValue();
                                        System.out.printf("Price: %f, confidence: %.2f%n",
                                            price, formField.getConfidence());
                                    }
                                }
                                if ("TotalPrice".equals(key)) {
                                    if (formField.getValue() instanceof Float) {
                                        Float totalPrice = (Float) formField.getValue();
                                        System.out.printf("Total Price: %f, confidence: %.2f%n",
                                            totalPrice, formField.getConfidence());
                                    }
                                }
                            });
                        }
                    });
                }
            }
            System.out.print("-----------------------------------");
        }
    }

Line commented on: if (merchantNameFieldValue instanceof String) {

Revised code:
public static void main(final String[] args) {
        
        FormRecognizerClient client = new FormRecognizerClientBuilder()
            .credential(new AzureKeyCredential("{key}"))
            .endpoint("https:
            .buildClient();

        String receiptUrl = "https:
            + "/azure-ai-formrecognizer/src/samples/java/sample-forms/receipts/contoso-allinone.jpg";
        SyncPoller<OperationResult, List<RecognizedForm>> recognizeReceiptPoller =
            client.beginRecognizeReceiptsFromUrl(receiptUrl);

        List<RecognizedForm> receiptPageResults = recognizeReceiptPoller.getFinalResult();

        for (int i = 0; i < receiptPageResults.size(); i++) {
            RecognizedForm recognizedForm = receiptPageResults.get(i);
            Map<String, FormField<?>> recognizedFields = recognizedForm.getFields();
            System.out.printf("----------- Recognized Receipt page %d -----------%n", i);
            FormField<?> merchantNameField = recognizedFields.get("MerchantName");
            if (merchantNameField != null) {
                if (FieldValueType.STRING.equals(merchantNameField.getValueType())) {
                    String merchantName = FieldValueType.STRING.cast(merchantNameField);
                    System.out.printf("Merchant Name: %s, confidence: %.2f%n",
                        merchantName, merchantNameField.getConfidence());
                }
            }

            FormField<?> merchantAddressField = recognizedFields.get("MerchantAddress");
            if (merchantAddressField != null) {
                if (FieldValueType.STRING.equals(merchantNameField.getValueType())) {
                    String merchantAddress = FieldValueType.STRING.cast(merchantAddressField);
                    System.out.printf("Merchant Address: %s, confidence: %.2f%n",
                        merchantAddress, merchantAddressField.getConfidence());
                }
            }

            FormField<?> merchantPhoneNumberField = recognizedFields.get("MerchantPhoneNumber");
            if (merchantPhoneNumberField != null) {
                if (FieldValueType.PHONE_NUMBER.equals(merchantNameField.getValueType())) {
                    String merchantAddress = FieldValueType.PHONE_NUMBER.cast(merchantPhoneNumberField);
                    System.out.printf("Merchant Phone number: %s, confidence: %.2f%n",
                        merchantAddress, merchantPhoneNumberField.getConfidence());
                }
            }

            FormField<?> transactionDateField = recognizedFields.get("TransactionDate");
            if (transactionDateField != null) {
                if (FieldValueType.DATE.equals(transactionDateField.getValueType())) {
                    LocalDate transactionDate = FieldValueType.DATE.cast(transactionDateField);
                    System.out.printf("Transaction Date: %s, confidence: %.2f%n",
                        transactionDate, transactionDateField.getConfidence());
                }
            }

            FormField<?> receiptItemsField = recognizedFields.get("Items");
            if (receiptItemsField != null) {
                System.out.printf("Receipt Items: %n");
                if (FieldValueType.LIST.equals(receiptItemsField.getValueType())) {
                    List<FormField<?>> receiptItems = FieldValueType.LIST.cast(receiptItemsField);
                    receiptItems.forEach(receiptItem -> {
                        if (FieldValueType.MAP.equals(receiptItem.getValueType())) {
                            Map<String, FormField<?>> formFieldMap = FieldValueType.MAP.cast(receiptItem);
                            formFieldMap.forEach((key, formField) -> {
                                if ("Name".equals(key)) {
                                    if (FieldValueType.STRING.equals(formField.getValueType())) {
                                        String name = FieldValueType.STRING.cast(formField);
                                        System.out.printf("Name: %s, confidence: %.2fs%n",
                                            name, formField.getConfidence());
                                    }
                                }
                                if ("Quantity".equals(key)) {
                                    if (FieldValueType.DOUBLE.equals(formField.getValueType())) {
                                        Float quantity = FieldValueType.DOUBLE.cast(formField);
                                        System.out.printf("Quantity: %f, confidence: %.2f%n",
                                            quantity, formField.getConfidence());
                                    }
                                }
                                if ("Price".equals(key)) {
                                    if (FieldValueType.DOUBLE.equals(formField.getValueType())) {
                                        Float price = FieldValueType.DOUBLE.cast(formField);
                                        System.out.printf("Price: %f, confidence: %.2f%n",
                                            price, formField.getConfidence());
                                    }
                                }
                                if ("TotalPrice".equals(key)) {
                                    if (FieldValueType.DOUBLE.equals(formField.getValueType())) {
                                        Float totalPrice = FieldValueType.DOUBLE.cast(formField);
                                        System.out.printf("Total Price: %f, confidence: %.2f%n",
                                            totalPrice, formField.getConfidence());
                                    }
                                }
                            });
                        }
                    });
                }
            }
            System.out.print("-----------------------------------");
        }
    }