blob: 1109e9221bcb530d8cc7c021e4af7117d6358ec9 [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.soam.loss;
17
18import java.time.Duration;
19import java.time.Instant;
20
21import org.onosproject.incubator.net.l2monitoring.soam.SoamId;
22
23/**
24 * The default implementation of LossMeasurementStatHistory.
25 * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatHistory}
26 */
27public final class DefaultLmStatHistory extends DefaultLmStat
28 implements LossMeasurementStatHistory {
29 private final SoamId historyStatsId;
30 private final Instant endTime;
31
32 protected DefaultLmStatHistory(DefaultLmStatHistoryBuilder builder) {
33 super(builder);
34 this.historyStatsId = builder.historyStatsId;
35 this.endTime = builder.endTime;
36 }
37
38 @Override
39 public SoamId historyStatsId() {
40 return historyStatsId;
41 }
42
43
44 @Override
45 public Instant endTime() {
46 return endTime;
47 }
48
49 public static LmStatHistoryBuilder builder(Duration elapsedTime,
50 boolean suspectStatus, SoamId historyStatsId, Instant endTime) {
51 return new DefaultLmStatHistoryBuilder(elapsedTime,
52 suspectStatus, historyStatsId, endTime);
53 }
54
55 private static class DefaultLmStatHistoryBuilder extends DefaultLmStatBuilder
56 implements LmStatHistoryBuilder {
57 private final SoamId historyStatsId;
58 private final Instant endTime;
59
60 protected DefaultLmStatHistoryBuilder(Duration elapsedTime,
61 boolean suspectStatus, SoamId historyStatsId, Instant endTime) {
62 super(elapsedTime, suspectStatus);
63 this.historyStatsId = historyStatsId;
64 this.endTime = endTime;
65 }
66
67 @Override
68 public LossMeasurementStatHistory build() {
69 return new DefaultLmStatHistory(this);
70 }
71 }
72
73
74}