- public byte[] put(PCEPObject obj) {
- if (!(obj instanceof PCEPExcludeRouteObject))
- throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + obj.getClass() + ". Needed PCEPExcludeRouteObject.");
-
- assert !(((PCEPExcludeRouteObject) obj).getSubobjects().isEmpty()) : "Empty Exclude Route Object.";
-
- final byte[] subObjsBytes = PCEPXROSubobjectParser.put(((PCEPExcludeRouteObject) obj).getSubobjects());
- final byte[] retBytes = new byte[this.SO_F_OFFSET + subObjsBytes.length];
- final BitSet flags = new BitSet(this.FLAGS_F_LENGTH * Byte.SIZE);
- flags.set(this.F_FLAG_OFFSET, ((PCEPExcludeRouteObject) obj).isFail());
- ByteArray.copyWhole(ByteArray.bitSetToBytes(flags, this.FLAGS_F_LENGTH), retBytes, this.FLAGS_F_OFFSET);
- ByteArray.copyWhole(subObjsBytes, retBytes, this.SO_F_OFFSET);
+ public byte[] serializeObject(final Object object) {
+ if (!(object instanceof Xro)) {
+ throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed ExcludeRouteObject.");
+ }
+ final Xro obj = (Xro) object;
+ assert !(obj.getSubobjects().isEmpty()) : "Empty Excluded Route Object.";
+ final byte[] bytes = serializeSubobject(obj.getSubobjects());
+ final byte[] result = new byte[FLAGS_OFFSET + 1 + bytes.length];
+ if (obj.getFlags().isFail()) {
+ result[FLAGS_OFFSET] = 1;
+ }
+ ByteArray.copyWhole(bytes, result, FLAGS_OFFSET + 1);
+ return result;
+ }