@Test public void testAsBytes() throws Exception { channelBuffer = ChannelBuffers.copiedBuffer(internalReachability); reachability.readFrom(channelBuffer); result3 = reachability.asBytes(); assertThat(result3, is(notNullValue())); }
public byte[] asBytes() { List<Byte> bytes = new ArrayList<>(); bytes.add(this.defaultMetric()); int temp = this.delayMetric(); String hsbBits = ""; if (this.isDelayMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isDelayIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; String binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.expenseMetric(); hsbBits = ""; if (this.isExpenseMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.errorMetric(); hsbBits = ""; if (this.isErrorMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); bytes.addAll(Bytes.asList(this.getIpAddress().toOctets())); bytes.addAll(Bytes.asList(this.getSubnetAddres().toOctets())); return Bytes.toArray(bytes); }
MetricOfInternalReachability { public byte[] asBytes() { List<Byte> bytes = new ArrayList<>(); bytes.add(this.defaultMetric()); int temp = this.delayMetric(); String hsbBits = ""; if (this.isDelayMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isDelayIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; String binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.expenseMetric(); hsbBits = ""; if (this.isExpenseMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.errorMetric(); hsbBits = ""; if (this.isErrorMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); bytes.addAll(Bytes.asList(this.getIpAddress().toOctets())); bytes.addAll(Bytes.asList(this.getSubnetAddres().toOctets())); return Bytes.toArray(bytes); } }
MetricOfInternalReachability { public byte[] asBytes() { List<Byte> bytes = new ArrayList<>(); bytes.add(this.defaultMetric()); int temp = this.delayMetric(); String hsbBits = ""; if (this.isDelayMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isDelayIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; String binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.expenseMetric(); hsbBits = ""; if (this.isExpenseMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.errorMetric(); hsbBits = ""; if (this.isErrorMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); bytes.addAll(Bytes.asList(this.getIpAddress().toOctets())); bytes.addAll(Bytes.asList(this.getSubnetAddres().toOctets())); return Bytes.toArray(bytes); }  }
MetricOfInternalReachability { public byte[] asBytes() { List<Byte> bytes = new ArrayList<>(); bytes.add(this.defaultMetric()); int temp = this.delayMetric(); String hsbBits = ""; if (this.isDelayMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isDelayIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; String binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.expenseMetric(); hsbBits = ""; if (this.isExpenseMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.errorMetric(); hsbBits = ""; if (this.isErrorMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); bytes.addAll(Bytes.asList(this.getIpAddress().toOctets())); bytes.addAll(Bytes.asList(this.getSubnetAddres().toOctets())); return Bytes.toArray(bytes); }  Ip4Address getIpAddress(); void setIpAddress(Ip4Address ipAddress); Ip4Address getSubnetAddres(); void setSubnetAddres(Ip4Address subnetAddres); boolean isErrorIsInternal(); void setErrorIsInternal(boolean errorIsInternal); boolean isExpenseIsInternal(); void setExpenseIsInternal(boolean expenseIsInternal); boolean isDelayIsInternal(); void setDelayIsInternal(boolean delayIsInternal); boolean isDefaultDistributionDown(); void setDefaultDistributionDown(boolean defaultDistributionDown); boolean isDefaultIsInternal(); void setDefaultIsInternal(boolean defaultIsInternal); boolean isErrorMetricSupported(); void setErrorMetricSupported(boolean errorMetricSupported); boolean isExpenseMetricSupported(); void setExpenseMetricSupported(boolean expenseMetricSupported); boolean isDelayMetricSupported(); void setDelayMetricSupported(boolean delayMetricSupported); byte errorMetric(); void setErrorMetric(byte errorMetric); byte expenseMetric(); void setExpenseMetric(byte expenseMetric); byte delayMetric(); void setDelayMetric(byte delayMetric); byte defaultMetric(); void setDefaultMetric(byte defaultMetric); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); @Override String toString(); }
MetricOfInternalReachability { public byte[] asBytes() { List<Byte> bytes = new ArrayList<>(); bytes.add(this.defaultMetric()); int temp = this.delayMetric(); String hsbBits = ""; if (this.isDelayMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isDelayIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; String binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.expenseMetric(); hsbBits = ""; if (this.isExpenseMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); temp = this.errorMetric(); hsbBits = ""; if (this.isErrorMetricSupported()) { hsbBits = "0" + hsbBits; } else { hsbBits = "1" + hsbBits; } if (this.isExpenseIsInternal()) { hsbBits = hsbBits + "0"; } else { hsbBits = hsbBits + "1"; } hsbBits = hsbBits + "00"; binary = hsbBits + IsisUtil.toFourBitBinary(Integer.toBinaryString(temp)); bytes.add((byte) Integer.parseInt(binary, 2)); bytes.addAll(Bytes.asList(this.getIpAddress().toOctets())); bytes.addAll(Bytes.asList(this.getSubnetAddres().toOctets())); return Bytes.toArray(bytes); }  Ip4Address getIpAddress(); void setIpAddress(Ip4Address ipAddress); Ip4Address getSubnetAddres(); void setSubnetAddres(Ip4Address subnetAddres); boolean isErrorIsInternal(); void setErrorIsInternal(boolean errorIsInternal); boolean isExpenseIsInternal(); void setExpenseIsInternal(boolean expenseIsInternal); boolean isDelayIsInternal(); void setDelayIsInternal(boolean delayIsInternal); boolean isDefaultDistributionDown(); void setDefaultDistributionDown(boolean defaultDistributionDown); boolean isDefaultIsInternal(); void setDefaultIsInternal(boolean defaultIsInternal); boolean isErrorMetricSupported(); void setErrorMetricSupported(boolean errorMetricSupported); boolean isExpenseMetricSupported(); void setExpenseMetricSupported(boolean expenseMetricSupported); boolean isDelayMetricSupported(); void setDelayMetricSupported(boolean delayMetricSupported); byte errorMetric(); void setErrorMetric(byte errorMetric); byte expenseMetric(); void setExpenseMetric(byte expenseMetric); byte delayMetric(); void setDelayMetric(byte delayMetric); byte defaultMetric(); void setDefaultMetric(byte defaultMetric); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); @Override String toString();  }