Sithara Punnassery | 589fac2 | 2016-10-03 11:51:53 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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.elasticcfg; |
| 17 | |
| 18 | import java.util.Set; |
| 19 | |
| 20 | /** |
| 21 | * Abstraction for Filters that can be used while traversing the PropConfig stores. |
| 22 | * This abstraction allows to select entries of interest based on various criteria |
| 23 | * defined by this interface. |
| 24 | * Only criteria based on {@code ConfigNodePath} are supported currently. |
| 25 | * Filters can be used with "GET" methods of {@code ProprietaryConfigService} |
| 26 | */ |
| 27 | public interface ConfigFilter { |
| 28 | /** |
| 29 | * Builder for ConfigFilter. |
| 30 | */ |
| 31 | interface Builder { |
| 32 | /** |
| 33 | * Adds new ConfigNodePath filtering criteria to a ConfigFilter object. |
| 34 | * If the same ConfigNodePath is already part of the criteria |
| 35 | * for the object, it will not be added again, but will not throw any exceptions. |
| 36 | * This will not check for the validity of the ConfigNodePath. |
| 37 | * |
| 38 | * @param add new criteria |
| 39 | * @return a ConfigFilter builder |
| 40 | */ |
| 41 | Builder addCriteria(Set<ConfigNodePath> add); |
| 42 | |
| 43 | /** |
| 44 | * Removes the given ConfigNodePath filtering criteria from a ConfigFilter object. |
| 45 | * If the ConfigNodePath was NOT already part of the criteria for |
| 46 | * the object, it will not be removed, but will not throw any exceptions. |
| 47 | * This will not check for the validity of the PropCfgInstancePaths. |
| 48 | * |
| 49 | * @param remove criteria to be removed |
| 50 | * @return a ConfigFilter builder |
| 51 | */ |
| 52 | Builder removeCriteria(Set<ConfigNodePath> remove); |
| 53 | |
| 54 | /** |
| 55 | * Builds an immutable ConfigFilter entity. |
| 56 | * |
| 57 | * @return ConfigFilter |
| 58 | */ |
| 59 | ConfigFilter build(); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Method to list all the ConfigNodePath criteria that are in place for a ConfigFilter. |
| 64 | * |
| 65 | * @return Set of ConfigNodePath criteria for this entity |
| 66 | */ |
| 67 | Set<ConfigNodePath> getCriteria(); |
| 68 | |
| 69 | /** |
| 70 | * Method to create a filter that include all entries rejected by the criteria. |
| 71 | * |
| 72 | * @param original filter object with a criteria set |
| 73 | * @return ConfigFilter object with negated criteria set |
| 74 | * @throws InvalidFilterException if the received ConfigFilter object |
| 75 | * was null or if it had an empty criteria set |
| 76 | */ |
| 77 | ConfigFilter negateFilter(ConfigFilter original); |
| 78 | |
| 79 | /** |
| 80 | * Method to check if the ConfigFilter has an empty criteria set. |
| 81 | * |
| 82 | * @return {@code true} if criteria set is empty, {@code true} otherwise. |
| 83 | */ |
| 84 | boolean isEmptyFilter(); |
| 85 | } |