blob: c3c855e1fb050d3c9c49d12daf056c79bddb761f [file] [log] [blame]
Aaron Kruglikov92511f22015-10-12 14:39:04 -07001/*
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
17package org.onosproject.persistence;
18
19
20import org.onosproject.store.service.Serializer;
21
22import java.util.Map;
23
24/**
25 * The interface for a persistent map builder for use with mapDB.
26 */
27public 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}