class IsoAddress implements Serializable {

  @Override
  @JsonValue
  public String toString() {
    // AA
    StringBuilder sb = new StringBuilder(String.format("%02X", _afi));
    if ((_areaId.length & 0x1) == 0) {
      // even number of bytes
      for (int i = 0; i < _areaId.length; i += 2) {
        // .BBBB
        sb.append(String.format(".%02X%02X", _areaId[i], _areaId[i + 1]));
      }
      for (int i = 0; i < SYSTEM_ID_SIZE; i += 2) {
        // .CCCC
        sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1]));
      }
      // .DD
      sb.append(String.format(".%02X", _nSel));
    } else {
      // odd number of bytes
      int areaIdOffset = 0;
      for (areaIdOffset = 0; areaIdOffset < _areaId.length - 1; areaIdOffset += 2) {
        // .BBBB
        sb.append(String.format(".%02X%02X", _areaId[areaIdOffset], _areaId[areaIdOffset + 1]));
      }
      // .BB
      sb.append(String.format(".%02X", _areaId[areaIdOffset]));
      // CC
      sb.append(String.format("%02X", _systemId[0]));
      for (int i = 1; i < SYSTEM_ID_SIZE - 2; i += 2) {
        // .CCCC
        sb.append(String.format(".%02X%02X", _systemId[i], _systemId[i + 1]));
      }
      // .CC
      sb.append(String.format(".%02X", _systemId[SYSTEM_ID_SIZE - 1]));
      // DD
      sb.append(String.format("%02X", _nSel));
    }
    return sb.toString();
  }

  public  IsoAddress(@Nonnull String isoAddressStr);

}