class ColumnHeaderParser {

    public EntityTypeField readFieldColumn(String name) {
        if (StringUtils.isBlank(name)) {
            throw new MetadataReadingException("Missing column name.");
        }
        String[] chunks = name.split(NAME_DELIMITER);
        if (chunks.length == 1) {
            return new EntityTypeField(chunks[0]);
        } else if (chunks.length == PATH_COLUMN_PARTS && chunks[1].equals(PATH_TYPE)) {
            return new EntityTypeField(chunks[0], PATH_TYPE);
        } else if (chunks.length == REFERENCE_COLUMN_PARTS) {
            if (!REFERENCE_SUFFIX.equals(chunks[chunks.length - 1])) {
                throw new MetadataReadingException("Reference field column must match format: 'Name:Type:ID'.");
            }
            return new EntityTypeField(chunks[0], chunks[1], true, false);
        } else if (chunks.length == MEMBERSHIP_COLUMN_PARTS && MEMBERSHIP_PREFIX.equals(chunks[0])) {
            if (!REFERENCE_SUFFIX.equals(chunks[chunks.length - 1])) {
                throw new MetadataReadingException(
                        "Membership field column must match format: 'membership:Name:Type:ID'.");
            }
            return new EntityTypeField(chunks[1], chunks[2], true, true);
        }
        throw new MetadataReadingException("Unknown field column format");
    }

}