blob: 790278a6a04ffc71da7463a2742d7f7627ea300a [file] [log] [blame]
Sean Condon0e89bda2017-03-21 14:23:19 +00001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.incubator.net.l2monitoring.cfm;
17
18import org.onlab.packet.MacAddress;
19import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
20
21import java.util.BitSet;
22
23/**
24 * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.cfm.MepLtCreate}.
25 */
26public final class DefaultMepLtCreate implements MepLtCreate {
27 private final MacAddress remoteMepAddress;
28 private final MepId remoteMepId;
29 private BitSet transmitLtmFlags;
30 private Short defaultTtl;
31
32 private DefaultMepLtCreate(DefaultMepLtCreateBuilder builder) {
33 this.remoteMepAddress = builder.remoteMepAddress;
34 this.remoteMepId = builder.remoteMepId;
35 this.defaultTtl = builder.defaultTtl;
36 this.transmitLtmFlags = builder.transmitLtmFlags;
37 }
38
39 @Override
40 public MacAddress remoteMepAddress() {
41 return remoteMepAddress;
42 }
43
44 @Override
45 public MepId remoteMepId() {
46 return remoteMepId;
47 }
48
49 @Override
50 public BitSet transmitLtmFlags() {
51 return transmitLtmFlags;
52 }
53
54 @Override
55 public Short defaultTtl() {
56 return defaultTtl;
57 }
58
59 public static final MepLtCreate.MepLtCreateBuilder builder(MacAddress remoteMepAddress) {
60 return new DefaultMepLtCreate.DefaultMepLtCreateBuilder(remoteMepAddress);
61 }
62
63 public static final MepLtCreate.MepLtCreateBuilder builder(MepId remoteMepId) {
64 return new DefaultMepLtCreate.DefaultMepLtCreateBuilder(remoteMepId);
65 }
66
67 private static final class DefaultMepLtCreateBuilder implements MepLtCreate.MepLtCreateBuilder {
68 private final MacAddress remoteMepAddress;
69 private final MepId remoteMepId;
70 private BitSet transmitLtmFlags;
71 private Short defaultTtl;
72
73 private DefaultMepLtCreateBuilder(MacAddress remoteMepAddress) {
74 this.remoteMepId = null;
75 this.remoteMepAddress = remoteMepAddress;
76 }
77
78 private DefaultMepLtCreateBuilder(MepId remoteMepId) {
79 this.remoteMepId = remoteMepId;
80 this.remoteMepAddress = null;
81 }
82
83 @Override
84 public MepLtCreateBuilder transmitLtmFlags(BitSet transmitLtmFlags) {
85 this.transmitLtmFlags = transmitLtmFlags;
86 return this;
87 }
88
89 @Override
90 public MepLtCreateBuilder defaultTtl(Short defaultTtl) {
91 this.defaultTtl = defaultTtl;
92 return this;
93 }
94
95 @Override
96 public MepLtCreate build() {
97 return new DefaultMepLtCreate(this);
98 }
99 }
100}