1 | /* |
2 | * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, |
3 | * and the EPL 1.0 (http://h2database.com/html/license.html). |
4 | * Initial Developer: H2 Group |
5 | */ |
6 | package org.h2.mvstore; |
7 | |
8 | import org.h2.mvstore.type.DataType; |
9 | import org.h2.mvstore.type.ObjectDataType; |
10 | |
11 | /** |
12 | * A class used for backward compatibility. |
13 | * |
14 | * @param <K> the key type |
15 | * @param <V> the value type |
16 | */ |
17 | public class MVMapConcurrent<K, V> extends MVMap<K, V> { |
18 | |
19 | public MVMapConcurrent(DataType keyType, DataType valueType) { |
20 | super(keyType, valueType); |
21 | } |
22 | |
23 | /** |
24 | * A builder for this class. |
25 | * |
26 | * @param <K> the key type |
27 | * @param <V> the value type |
28 | */ |
29 | public static class Builder<K, V> implements |
30 | MapBuilder<MVMapConcurrent<K, V>, K, V> { |
31 | |
32 | protected DataType keyType; |
33 | protected DataType valueType; |
34 | |
35 | /** |
36 | * Create a new builder with the default key and value data types. |
37 | */ |
38 | public Builder() { |
39 | // ignore |
40 | } |
41 | |
42 | /** |
43 | * Set the key data type. |
44 | * |
45 | * @param keyType the key type |
46 | * @return this |
47 | */ |
48 | public Builder<K, V> keyType(DataType keyType) { |
49 | this.keyType = keyType; |
50 | return this; |
51 | } |
52 | |
53 | /** |
54 | * Set the key data type. |
55 | * |
56 | * @param valueType the key type |
57 | * @return this |
58 | */ |
59 | public Builder<K, V> valueType(DataType valueType) { |
60 | this.valueType = valueType; |
61 | return this; |
62 | } |
63 | |
64 | @Override |
65 | public MVMapConcurrent<K, V> create() { |
66 | if (keyType == null) { |
67 | keyType = new ObjectDataType(); |
68 | } |
69 | if (valueType == null) { |
70 | valueType = new ObjectDataType(); |
71 | } |
72 | return new MVMapConcurrent<K, V>(keyType, valueType); |
73 | } |
74 | |
75 | } |
76 | |
77 | } |