blob: 4db368360fb99bb4d0016fe2d9c2a009662576f7 [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.delay;
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 DelayMeasurementStatHistory.
25 * {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatHistory}.
26 */
27public class DefaultDelayMeasurementStatHistory extends DefaultDelayMeasurementStat
28 implements DelayMeasurementStatHistory {
29
30 private final SoamId historyStatsId;
31 private final Instant endTime;
32
33 protected DefaultDelayMeasurementStatHistory(DefaultDmStatHistoryBuilder builder) {
34 super(builder);
35 this.historyStatsId = builder.historyStatsId;
36 this.endTime = builder.endTime;
37 }
38
39 @Override
40 public SoamId historyStatsId() {
41 return historyStatsId;
42 }
43
44 @Override
45 public Instant endTime() {
46 return endTime;
47 }
48
49 public static DmStatHistoryBuilder builder(SoamId historyStatsId,
50 Duration elapsedTime, boolean suspectStatus) {
51 return new DefaultDmStatHistoryBuilder(
52 historyStatsId, elapsedTime, suspectStatus);
53 }
54
55 /**
56 * Builder for {@link org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementStatHistory}.
57 */
58 private static final class DefaultDmStatHistoryBuilder
59 extends DefaultDmStatBuilder implements DmStatHistoryBuilder {
60 private final SoamId historyStatsId;
61 private Instant endTime;
62
63 private DefaultDmStatHistoryBuilder(SoamId historyStatsId,
64 Duration elapsedTime, boolean suspectStatus) {
65 super(elapsedTime, suspectStatus);
66 this.historyStatsId = historyStatsId;
67 }
68
69 @Override
70 public DmStatHistoryBuilder endTime(Instant endTime) {
71 this.endTime = endTime;
72 return this;
73 }
74
75 @Override
76 public DelayMeasurementStat build() {
77 return new DefaultDelayMeasurementStatHistory(this);
78 }
79 }
80}