Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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.store.service; |
| 17 | |
| 18 | import java.util.Set; |
| 19 | |
| 20 | /** |
| 21 | * Builder for distributed set. |
| 22 | * |
| 23 | * @param <E> type set elements. |
| 24 | */ |
| 25 | public interface SetBuilder<E> { |
| 26 | |
| 27 | /** |
| 28 | * Sets the name of the set. |
| 29 | * <p> |
| 30 | * Each set is identified by a unique name. |
| 31 | * </p> |
| 32 | * <p> |
| 33 | * Note: This is a mandatory parameter. |
| 34 | * </p> |
| 35 | * |
| 36 | * @param name name of the set |
| 37 | * @return this SetBuilder |
| 38 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 39 | SetBuilder<E> withName(String name); |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Sets a serializer that can be used to serialize |
| 43 | * the elements add to the set. The serializer |
| 44 | * builder should be pre-populated with any classes that will be |
| 45 | * put into the set. |
| 46 | * <p> |
| 47 | * Note: This is a mandatory parameter. |
| 48 | * </p> |
| 49 | * |
| 50 | * @param serializer serializer |
| 51 | * @return this SetBuilder |
| 52 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 53 | SetBuilder<E> withSerializer(Serializer serializer); |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
Madan Jampani | 02b7fb8 | 2015-05-01 13:01:20 -0700 | [diff] [blame] | 56 | * Disables set updates. |
| 57 | * <p> |
| 58 | * Attempt to update the built set will throw {@code UnsupportedOperationException}. |
| 59 | * |
| 60 | * @return this SetBuilder |
| 61 | */ |
| 62 | SetBuilder<E> withUpdatesDisabled(); |
| 63 | |
| 64 | /** |
Madan Jampani | 08706ce | 2015-04-01 14:49:28 -0700 | [diff] [blame] | 65 | * Builds an set based on the configuration options |
| 66 | * supplied to this builder. |
| 67 | * |
| 68 | * @return new set |
| 69 | * @throws java.lang.RuntimeException if a mandatory parameter is missing |
| 70 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 71 | Set<E> build(); |
| 72 | } |