Seyeon Jeong | ac12956 | 2020-02-28 01:17:34 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-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 | |
| 17 | package org.onosproject.t3.api; |
| 18 | |
| 19 | import java.text.SimpleDateFormat; |
| 20 | |
| 21 | /** |
| 22 | * Basic descriptions about a single Network information Base (NIB) instance. |
| 23 | */ |
| 24 | public class NibProfile { |
| 25 | // default false means the contents of this NIB are empty at the instantiation |
| 26 | private boolean valid = false; |
| 27 | private String date; |
| 28 | private SourceType sourceType; |
| 29 | |
| 30 | public enum SourceType { |
| 31 | /** |
| 32 | * Provided by dump files. |
| 33 | */ |
| 34 | FILE, |
| 35 | /** |
| 36 | * Provided by a running system. |
| 37 | */ |
| 38 | SNAPSHOT |
| 39 | } |
| 40 | |
| 41 | public NibProfile(long date, SourceType sourceType) { |
| 42 | this.valid = true; |
| 43 | this.date = new SimpleDateFormat("dd-MM-yyyy hh:mm").format(date); |
| 44 | this.sourceType = sourceType; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns the validity state of this NIB. |
| 49 | * |
| 50 | * @return true once this profile is initialized |
| 51 | */ |
| 52 | public boolean isValid() { |
| 53 | return valid; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the time this NIB has been filled. |
| 58 | * |
| 59 | * @return string representation for the time |
| 60 | */ |
| 61 | public String date() { |
| 62 | return date; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the type of the source used to fill this NIB. |
| 67 | * |
| 68 | * @return source type |
| 69 | */ |
| 70 | public SourceType sourceType() { |
| 71 | return sourceType; |
| 72 | } |
| 73 | |
| 74 | } |