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 | /** |
| 22 | * The default implementation of LossAvailabilityStatCurrent. |
| 23 | * {@link org.onosproject.incubator.net.l2monitoring.soam.loss.LossAvailabilityStatCurrent}. |
| 24 | */ |
| 25 | public final class DefaultLaStatCurrent extends DefaultLaStat |
| 26 | implements LossAvailabilityStatCurrent { |
| 27 | private final Instant startTime; |
| 28 | |
| 29 | private DefaultLaStatCurrent(DefaultLaStatCurrentBuilder 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 LaStatCurrentBuilder builder(Duration elapsedTime, |
| 40 | boolean suspectStatus, Instant startTime) { |
| 41 | return new DefaultLaStatCurrentBuilder(elapsedTime, suspectStatus, |
| 42 | startTime); |
| 43 | } |
| 44 | |
| 45 | private static final class DefaultLaStatCurrentBuilder |
| 46 | extends DefaultLaStatBuilder implements LaStatCurrentBuilder { |
| 47 | private Instant startTime; |
| 48 | |
| 49 | protected DefaultLaStatCurrentBuilder(Duration elapsedTime, |
| 50 | boolean suspectStatus, Instant startTime) { |
| 51 | super(elapsedTime, suspectStatus); |
| 52 | this.startTime = startTime; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public LossAvailabilityStatCurrent build() { |
| 57 | return new DefaultLaStatCurrent(this); |
| 58 | } |
| 59 | } |
| 60 | } |