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.soam.delay; |
| 17 | |
| 18 | import java.time.Duration; |
| 19 | import java.time.Instant; |
| 20 | |
| 21 | import org.onosproject.incubator.net.l2monitoring.soam.SoamId; |
| 22 | |
| 23 | /** |
| 24 | * The default implementation of DelayMeasurementStatHistory. |
Sean Condon | 3a1efef | 2018-02-24 13:16:03 +0000 | [diff] [blame] | 25 | * {@link DelayMeasurementStatHistory}. |
Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame] | 26 | */ |
| 27 | public 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 Condon | 3a1efef | 2018-02-24 13:16:03 +0000 | [diff] [blame] | 56 | * Builder for {@link DelayMeasurementStatHistory}. |
Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame] | 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 | } |