2 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.pcep.parser.object.unreach;
10 import static com.google.common.base.Preconditions.checkArgument;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObj;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCase;
20 public final class PCEPUnreachDestinationSerializer implements ObjectSerializer {
22 public void serializeObject(final Object object, final ByteBuf buffer) {
23 checkArgument(object instanceof UnreachDestinationObj,
24 "Wrong instance of PCEPObject. Passed %s. Needed UnreachDestinationObj.", object.getClass());
25 final UnreachDestinationObj uPObj = (UnreachDestinationObj) object;
26 final Destination destination = uPObj.getDestination();
27 final Boolean processing = object.getProcessingRule();
28 final Boolean ignore = object.getIgnore();
29 if (destination instanceof Ipv6DestinationCase) {
30 final Ipv6DestinationCase ipv6 = (Ipv6DestinationCase) destination;
31 PCEPIpv6UnreachDestinationParser.serializeObject(processing, ignore, ipv6, buffer);
32 } else if (destination instanceof Ipv4DestinationCase) {
33 final Ipv4DestinationCase ipv4 = (Ipv4DestinationCase) destination;
34 PCEPIpv4UnreachDestinationParser.serializeObject(processing, ignore, ipv4, buffer);