public List<Field> getSortedFields(Class<? extends Header> type) {
    if (sortedFieldsMap.containsKey(type)) return sortedFieldsMap.get(type);
    
    Field[] fields = type.getDeclaredFields();
    List<Field> headerFields = new ArrayList<Field>();
    
    for (Field field : fields) {
      if (field.isAnnotationPresent(HeaderField.class)) {
        headerFields.add(field);
      }
    }
    
    Collections.sort(headerFields, new Comparator<Field>() {
      @Override
      public int compare(Field first, Field second) {
        return first.getAnnotation(HeaderField.class).offset() - 
            second.getAnnotation(HeaderField.class).offset();
      }
    });
    
    sortedFieldsMap.put(type, headerFields);
    
    return headerFields;
  }