Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.incubator.net.l2monitoring.cfm; |
| 17 | |
| 18 | /** |
| 19 | * The default implementation of {@link org.onosproject.incubator.net.l2monitoring.cfm.MepLbEntry}. |
| 20 | */ |
| 21 | public final class DefaultMepLbEntry implements MepLbEntry { |
| 22 | private final long nextLbmIdentifier; |
| 23 | private final long countLbrTransmitted; |
| 24 | private final long countLbrReceived; |
| 25 | private final long countLbrValidInOrder; |
| 26 | private final long countLbrValidOutOfOrder; |
| 27 | private final long countLbrMacMisMatch; |
| 28 | |
| 29 | private DefaultMepLbEntry(DefaultMepLbEntryBuilder builder) { |
| 30 | this.nextLbmIdentifier = builder.nextLbmIdentifier; |
| 31 | this.countLbrTransmitted = builder.countLbrTransmitted; |
| 32 | this.countLbrReceived = builder.countLbrReceived; |
| 33 | this.countLbrValidInOrder = builder.countLbrValidInOrder; |
| 34 | this.countLbrValidOutOfOrder = builder.countLbrValidOutOfOrder; |
| 35 | this.countLbrMacMisMatch = builder.countLbrMacMisMatch; |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public long nextLbmIdentifier() { |
| 40 | return nextLbmIdentifier; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public long countLbrTransmitted() { |
| 45 | return countLbrTransmitted; |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public long countLbrReceived() { |
| 50 | return countLbrReceived; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public long countLbrValidInOrder() { |
| 55 | return countLbrValidInOrder; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public long countLbrValidOutOfOrder() { |
| 60 | return countLbrValidOutOfOrder; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public long countLbrMacMisMatch() { |
| 65 | return countLbrMacMisMatch; |
| 66 | } |
| 67 | |
| 68 | public static final MepLbEntryBuilder builder() { |
| 69 | return new DefaultMepLbEntryBuilder(); |
| 70 | } |
| 71 | |
| 72 | private static final class DefaultMepLbEntryBuilder implements MepLbEntryBuilder { |
| 73 | private long nextLbmIdentifier; |
| 74 | private long countLbrTransmitted; |
| 75 | private long countLbrReceived; |
| 76 | private long countLbrValidInOrder; |
| 77 | private long countLbrValidOutOfOrder; |
| 78 | private long countLbrMacMisMatch; |
| 79 | |
| 80 | private DefaultMepLbEntryBuilder() { |
| 81 | //Hidden |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public MepLbEntryBuilder nextLbmIdentifier(long nextLbmIdentifier) { |
| 86 | this.nextLbmIdentifier = nextLbmIdentifier; |
| 87 | return this; |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public MepLbEntryBuilder countLbrTransmitted(long countLbrTransmitted) { |
| 92 | this.countLbrTransmitted = countLbrTransmitted; |
| 93 | return this; |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public MepLbEntryBuilder countLbrReceived(long countLbrReceived) { |
| 98 | this.countLbrReceived = countLbrReceived; |
| 99 | return this; |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public MepLbEntryBuilder countLbrValidInOrder( |
| 104 | long countLbrValidInOrder) { |
| 105 | this.countLbrValidInOrder = countLbrValidInOrder; |
| 106 | return this; |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public MepLbEntryBuilder countLbrValidOutOfOrder( |
| 111 | long countLbrValidOutOfOrder) { |
| 112 | this.countLbrValidOutOfOrder = countLbrValidOutOfOrder; |
| 113 | return this; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public MepLbEntryBuilder countLbrMacMisMatch(long countLbrMacMisMatch) { |
| 118 | this.countLbrMacMisMatch = countLbrMacMisMatch; |
| 119 | return this; |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public MepLbEntry build() { |
| 124 | return new DefaultMepLbEntry(this); |
| 125 | } |
| 126 | } |
| 127 | } |