Code Clean Up
[bgpcep.git] / pcep / pcc-mock / src / main / java / org / opendaylight / protocol / pcep / pcc / mock / protocol / PCCServerPeerProposal.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.pcep.pcc.mock.protocol;
9
10 import com.google.common.base.Preconditions;
11 import java.math.BigInteger;
12 import java.net.InetSocketAddress;
13 import javax.annotation.Nonnull;
14 import org.opendaylight.protocol.pcep.PCEPPeerProposal;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs3;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs3Builder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.lsp.db.version.tlv.LspDbVersionBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
19
20 public class PCCServerPeerProposal implements PCEPPeerProposal {
21     private boolean isAfterReconnection;
22     private final BigInteger dbVersion;
23
24     public PCCServerPeerProposal(@Nonnull final BigInteger dbVersion) {
25         this.dbVersion = dbVersion;
26     }
27
28     @Override
29     public void setPeerSpecificProposal(@Nonnull final InetSocketAddress address, @Nonnull final TlvsBuilder openBuilder) {
30         Preconditions.checkNotNull(address);
31         final LspDbVersionBuilder lspDbVersionBuilder = new LspDbVersionBuilder();
32         if (this.isAfterReconnection) {
33             lspDbVersionBuilder.setLspDbVersionValue(this.dbVersion);
34         } else {
35             this.isAfterReconnection = true;
36         }
37         openBuilder.addAugmentation(Tlvs3.class, new Tlvs3Builder().setLspDbVersion(lspDbVersionBuilder.build()).build());
38     }
39 }