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.loss; |
| 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 LossAvailabilityStatHistory. |
| 25 | * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatHistory}. |
| 26 | */ |
| 27 | public final class DefaultLaStatHistory extends DefaultLaStat |
| 28 | implements LossAvailabilityStatHistory { |
| 29 | private final Instant endTime; |
| 30 | private final SoamId historyStatsId; |
| 31 | |
| 32 | private DefaultLaStatHistory(DefaultLaStatHistoryBuilder builder) { |
| 33 | super(builder); |
| 34 | this.endTime = builder.endTime; |
| 35 | this.historyStatsId = builder.historyStatsId; |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public Instant endTime() { |
| 40 | return endTime; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public SoamId historyStatsId() { |
| 45 | return historyStatsId; |
| 46 | } |
| 47 | |
| 48 | public static LaStatHistoryBuilder builder(Duration elapsedTime, |
| 49 | boolean suspectStatus, SoamId historyStatsId, Instant endTime) { |
| 50 | return new DefaultLaStatHistoryBuilder(elapsedTime, suspectStatus, |
| 51 | historyStatsId, endTime); |
| 52 | } |
| 53 | |
| 54 | private static final class DefaultLaStatHistoryBuilder |
| 55 | extends DefaultLaStatBuilder implements LaStatHistoryBuilder { |
| 56 | private Instant endTime; |
| 57 | private SoamId historyStatsId; |
| 58 | |
| 59 | protected DefaultLaStatHistoryBuilder(Duration elapsedTime, |
| 60 | boolean suspectStatus, SoamId historyStatsId, Instant endTime) { |
| 61 | super(elapsedTime, suspectStatus); |
| 62 | this.historyStatsId = historyStatsId; |
| 63 | this.endTime = endTime; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public LossAvailabilityStatHistory build() { |
| 68 | return new DefaultLaStatHistory(this); |
| 69 | } |
| 70 | } |
| 71 | } |