blob: d73578216e0289b56c39ca25be06720141bcff4a [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.
Sean Condon3a1efef2018-02-24 13:16:03 +000025 * {@link DelayMeasurementStatHistory}.
Sean Condon0e89bda2017-03-21 14:23:19 +000026 */
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 /**
Sean Condon3a1efef2018-02-24 13:16:03 +000056 * Builder for {@link DelayMeasurementStatHistory}.
Sean Condon0e89bda2017-03-21 14:23:19 +000057 */
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}