Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
InMemoryStateImpl |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 | * contributor license agreements. See the NOTICE file distributed with | |
4 | * this work for additional information regarding copyright ownership. | |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 | * (the "License"); you may not use this file except in compliance with | |
7 | * the License. You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | package org.apache.commons.id.uuid.state; | |
19 | ||
20 | import java.util.HashSet; | |
21 | import java.util.Set; | |
22 | ||
23 | /** | |
24 | * <p>The <code>InMemoryStateImpl</code> is an implementation of the | |
25 | * <code>State</code> interface.</p> | |
26 | * <p>This implementation is the <b>worst-case</b> scenario and provides | |
27 | * the least guarantee of no UUID duplication. This implementation is provided for | |
28 | * systems that truly have no other means of writing to or reading from stable | |
29 | * storage.</p> | |
30 | * | |
31 | * @author Commons-Id team | |
32 | * @version $Id: InMemoryStateImpl.java 480488 2006-11-29 08:57:26Z bayard $ | |
33 | */ | |
34 | 6 | public class InMemoryStateImpl implements State { |
35 | ||
36 | /** The nodes to return from the <code>State</code> implementation */ | |
37 | 1 | private static HashSet nodes = new HashSet(1); |
38 | ||
39 | /** | |
40 | * @see org.apache.commons.id.uuid.state.State#load() | |
41 | */ | |
42 | public void load() { | |
43 | 3 | Node one = new Node(StateHelper.randomNodeIdentifier()); |
44 | 0 | nodes.add(one); |
45 | 0 | } |
46 | ||
47 | /** | |
48 | * @see org.apache.commons.id.uuid.state.State#getNodes() | |
49 | */ | |
50 | public Set getNodes() { | |
51 | 0 | return nodes; |
52 | } | |
53 | ||
54 | /** | |
55 | * @see org.apache.commons.id.uuid.state.State#store(Set) | |
56 | */ | |
57 | public void store(Set nodesCollection) { | |
58 | // Nothing to do - this is the worse case senerio since with no | |
59 | // peristent storage. | |
60 | 0 | return; |
61 | } | |
62 | ||
63 | /** | |
64 | * @see org.apache.commons.id.uuid.state.State#store(Set, long) | |
65 | */ | |
66 | public void store(Set nodesCollection, long timestamp) { | |
67 | // Nothing to do - this is the worse case senerio since with no | |
68 | // peristent storage. | |
69 | 0 | return; |
70 | } | |
71 | ||
72 | /** | |
73 | * @see State#getSynchInterval | |
74 | */ | |
75 | public long getSynchInterval() { | |
76 | 1 | return Long.MAX_VALUE; |
77 | } | |
78 | } |