Move pcep base parser Activator to its own bundle
[bgpcep.git] / pcep / ietf-stateful07 / src / main / java / org / opendaylight / protocol / pcep / ietf / stateful07 / PCEPStatefulCapability.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.ietf.stateful07;
9
10 import java.net.InetSocketAddress;
11 import org.opendaylight.protocol.pcep.PCEPCapability;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1Builder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1Builder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
18
19 public class PCEPStatefulCapability implements PCEPCapability {
20
21     private final boolean stateful, active, instant, triggeredSync, triggeredResync, deltaLspSync, includeDbVersion;
22
23     public PCEPStatefulCapability(final boolean stateful, final boolean active, final boolean instant,
24         final boolean triggeredSync, final boolean triggeredResync, final boolean deltaLspSync, final boolean includeDbVersion){
25         this.stateful = stateful;
26         this.active = active;
27         this.instant = instant;
28         this.triggeredSync = triggeredSync;
29         this.triggeredResync = triggeredResync;
30         this.deltaLspSync = deltaLspSync;
31         this.includeDbVersion = includeDbVersion;
32     }
33
34     @Override
35     public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
36         if (this.stateful) {
37             builder.addAugmentation(
38                 Tlvs1.class, new Tlvs1Builder()
39                     .setStateful( new StatefulBuilder().setLspUpdateCapability(this.active)
40                         .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(this.instant).build())
41                         .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1Builder()
42                             .setTriggeredInitialSync(this.triggeredSync)
43                             .setTriggeredResync(this.triggeredResync)
44                             .setDeltaLspSyncCapability(this.deltaLspSync)
45                             .setIncludeDbVersion(this.includeDbVersion)
46                             .build())
47                         .build())
48                     .build());
49         }
50     }
51
52     public boolean isStateful() {
53         return this.stateful;
54     }
55
56     public boolean isActive() {
57         return this.active;
58     }
59
60     public boolean isInstant() {
61         return this.instant;
62     }
63
64     public boolean isTriggeredSync() {
65         return this.triggeredSync;
66     }
67
68     public boolean isTriggeredResync() {
69         return this.triggeredResync;
70     }
71
72     public boolean isDeltaLspSync() {
73         return this.deltaLspSync;
74     }
75
76     public boolean isIncludeDbVersion() {
77         return this.includeDbVersion;
78     }
79 }