// Path: src/main/java/com/qoomon/banking/swift/message/block/exception/BlockFieldParseException.java
// public class BlockFieldParseException extends Exception {
// 
// 
//     public BlockFieldParseException(String message) {
//         super(message);
//     }
// 
// 
//     public BlockFieldParseException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }
// 
// Path: src/main/java/com/qoomon/banking/swift/submessage/field/subfield/MessagePriority.java
// public enum MessagePriority {
// 
//     URGENT,
//     NORMAL,
//     SYSTEM;
// 
//     public static MessagePriority of(String value) {
//         switch (value) {
//             case "URGENT":
//             case "U":
//                 return URGENT;
//             case "NORMAL":
//             case "N":
//             case "":
//                 return NORMAL;
//             case "SYSTEM":
//             case "S":
//                 return SYSTEM;
//             default:
//                 throw new IllegalArgumentException("No mapping found for value '" + value + "'");
//         }
//     }
// 
//     public String asText(){
//         switch (this) {
//             case URGENT:
//                 return "U";
//             case NORMAL:
//                 return "N";
//             case SYSTEM:
//                 return "S";
//             default:
//                 throw new IllegalArgumentException("No mapping found for value '" + this + "'");
//         }
//     }
// }


import com.google.common.base.Preconditions;
import com.qoomon.banking.swift.message.block.exception.BlockFieldParseException;
import com.qoomon.banking.swift.submessage.field.subfield.MessagePriority;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
        Preconditions.checkArgument(block.getId().equals(ApplicationHeaderBlock.BLOCK_ID_2), "unexpected block id '%s'", block.getId());

        Matcher blockContentMatcher = BLOCK_CONTENT_PATTERN.matcher(block.getContent());
        if (!blockContentMatcher.matches()) {
            throw new BlockFieldParseException("Block '" + block.getId() + "' content did not match format " + BLOCK_CONTENT_PATTERN);
        }

        String mode = blockContentMatcher.group(1);
        if (!mode.equals(MODE_CODE)) {
            throw new BlockFieldParseException("Block '" + block.getId() + "' expect mod '" + MODE_CODE + "', but was " + mode);
        }

        String messageType = blockContentMatcher.group(2);
        String receiverAddress = blockContentMatcher.group(3);
        MessagePriority messagePriority = MessagePriority.of(blockContentMatcher.group(4));
        String deliveryMonitoring = blockContentMatcher.group(5);
        String obsolescencePeriod = blockContentMatcher.group(6);

        return new ApplicationHeaderInputBlock(messageType, receiverAddress, messagePriority, deliveryMonitoring, obsolescencePeriod);
    }

    public String getMessageType() {
        return messageType;
    }

    public String getReceiverAddress() {
        return receiverAddress;
    }

    public MessagePriority getMessagePriority() {
// Path: src/main/java/com/qoomon/banking/swift/message/block/exception/BlockFieldParseException.java
// public class BlockFieldParseException extends Exception {
// 
// 
//     public BlockFieldParseException(String message) {
//         super(message);
//     }
// 
// 
//     public BlockFieldParseException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
// }
// 
// Path: src/main/java/com/qoomon/banking/swift/submessage/field/subfield/MessagePriority.java
// public enum MessagePriority {
// 
//     URGENT,
//     NORMAL,
//     SYSTEM;
// 
//     public static MessagePriority of(String value) {
//         switch (value) {
//             case "URGENT":
//             case "U":
//                 return URGENT;
//             case "NORMAL":
//             case "N":
//             case "":
//                 return NORMAL;
//             case "SYSTEM":
//             case "S":
//                 return SYSTEM;
//             default:
//                 throw new IllegalArgumentException("No mapping found for value '" + value + "'");
//         }
//     }
// 
//     public String asText(){
//         switch (this) {
//             case URGENT:
//                 return "U";
//             case NORMAL:
//                 return "N";
//             case SYSTEM:
//                 return "S";
//             default:
//                 throw new IllegalArgumentException("No mapping found for value '" + this + "'");
//         }
//     }
// }


// Path: src/main/java/com/qoomon/banking/swift/message/block/ApplicationHeaderInputBlock.java
import com.google.common.base.Preconditions;
import com.qoomon.banking.swift.message.block.exception.BlockFieldParseException;
import com.qoomon.banking.swift.submessage.field.subfield.MessagePriority;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

        Preconditions.checkArgument(block.getId().equals(ApplicationHeaderBlock.BLOCK_ID_2), "unexpected block id '%s'", block.getId());

        Matcher blockContentMatcher = BLOCK_CONTENT_PATTERN.matcher(block.getContent());
        if (!blockContentMatcher.matches()) {
            throw new BlockFieldParseException("Block '" + block.getId() + "' content did not match format " + BLOCK_CONTENT_PATTERN);
        }

        String mode = blockContentMatcher.group(1);
        if (!mode.equals(MODE_CODE)) {
            throw new BlockFieldParseException("Block '" + block.getId() + "' expect mod '" + MODE_CODE + "', but was " + mode);
        }

        String messageType = blockContentMatcher.group(2);
        String receiverAddress = blockContentMatcher.group(3);
        MessagePriority messagePriority = MessagePriority.of(blockContentMatcher.group(4));
        String deliveryMonitoring = blockContentMatcher.group(5);
        String obsolescencePeriod = blockContentMatcher.group(6);

        return new ApplicationHeaderInputBlock(messageType, receiverAddress, messagePriority, deliveryMonitoring, obsolescencePeriod);
    }

    public String getMessageType() {
        return messageType;
    }

    public String getReceiverAddress() {
        return receiverAddress;
    }

    public MessagePriority getMessagePriority() {
        return messagePriority;