blob: 587789dcb28142e67a783e7aa0a9078b17187525 [file] [log] [blame]
Jordan Halterman2c045992018-03-20 21:33:00 -07001/*
2 * Copyright 2018-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 */
16package org.onosproject.store.service;
17
18import org.onosproject.store.primitives.DistributedPrimitiveOptions;
19
20/**
21 * Builder for {@link ConsistentMap} instances.
22 *
23 * @param <K> type for map key
24 * @param <V> type for map value
25 */
26public abstract class ConsistentMapOptions<O extends ConsistentMapOptions<O, K, V>, K, V>
27 extends DistributedPrimitiveOptions<O> {
28
29 private boolean nullValues = false;
30 private boolean purgeOnUninstall = false;
31
32 public ConsistentMapOptions() {
33 super(DistributedPrimitive.Type.CONSISTENT_MAP);
34 }
35
36 /**
37 * Enables null values in the map.
38 *
39 * @return this builder
40 */
41 public O withNullValues() {
42 nullValues = true;
43 return (O) this;
44 }
45
46 /**
47 * Clears map contents when the owning application is uninstalled.
48 *
49 * @return this builder
50 */
51 public O withPurgeOnUninstall() {
52 purgeOnUninstall = true;
53 return (O) this;
54 }
55
56 /**
57 * Returns whether null values are supported by the map.
58 *
59 * @return {@code true} if null values are supported; {@code false} otherwise
60 */
61 public boolean nullValues() {
62 return nullValues;
63 }
64
65 /**
66 * Returns if map entries need to be cleared when owning application is uninstalled.
67 * @return {@code true} if yes; {@code false} otherwise.
68 */
69 public boolean purgeOnUninstall() {
70 return purgeOnUninstall;
71 }
72
73}