Aaron Kruglikov | 92511f2 | 2015-10-12 14:39:04 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Aaron Kruglikov | 92511f2 | 2015-10-12 14:39:04 -0700 | [diff] [blame] | 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.persistence; |
| 18 | |
| 19 | |
| 20 | import org.onosproject.store.service.Serializer; |
| 21 | |
| 22 | import java.util.Map; |
| 23 | |
| 24 | /** |
| 25 | * The interface for a persistent map builder for use with mapDB. |
| 26 | */ |
| 27 | public interface PersistentMapBuilder<K, V> { |
| 28 | |
| 29 | /** |
| 30 | * Sets the name of this map. |
| 31 | * @param name the string name of this map |
| 32 | * @return a persistent map builder with the name option now set |
| 33 | */ |
| 34 | PersistentMapBuilder<K, V> withName(String name); |
| 35 | |
| 36 | /** |
| 37 | * Sets the key serializer to be used to serialize this map, this is a required parameter. |
| 38 | * @param serializer the serializer to be used for keys |
| 39 | * @return a persistent map builder with the key serializer set |
| 40 | */ |
| 41 | PersistentMapBuilder<K, V> withSerializer(Serializer serializer); |
| 42 | |
| 43 | /** |
| 44 | * Validates the map settings and then builds this map in the database. Throws an exception if invalid settings |
| 45 | * are found. |
| 46 | * @return The map that was created |
| 47 | */ |
| 48 | Map<K, V> build(); |
| 49 | } |