blob: 1920845dec8619d66e136a889446f3965264df64 [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
21/**
22 * The default implementation of LossMeasurementStatCurrent.
23 * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementStatCurrent}
24 */
25public final class DefaultLmStatCurrent extends DefaultLmStat
26 implements LossMeasurementStatCurrent {
27 private final Instant startTime;
28
29 protected DefaultLmStatCurrent(DefaultLmStatCurrentBuilder builder) {
30 super(builder);
31 this.startTime = builder.startTime;
32 }
33
34 @Override
35 public Instant startTime() {
36 return startTime;
37 }
38
39 public static LmStatCurrentBuilder builder(Duration elapsedTime,
40 boolean suspectStatus, Instant startTime) {
41 return new DefaultLmStatCurrentBuilder(elapsedTime,
42 suspectStatus, startTime);
43 }
44
45 private static class DefaultLmStatCurrentBuilder extends DefaultLmStatBuilder
46 implements LmStatCurrentBuilder {
47 private final Instant startTime;
48
49 protected DefaultLmStatCurrentBuilder(Duration elapsedTime,
50 boolean suspectStatus, Instant startTime) {
51 super(elapsedTime, suspectStatus);
52 this.startTime = startTime;
53 }
54
55 @Override
56 public LossMeasurementStatCurrent build() {
57 return new DefaultLmStatCurrent(this);
58 }
59 }
60}