]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.api.uuid/src/org/argeo/api/uuid/NoOpUuidFactory.java
Kerberos does not try to use shared state
[lgpl/argeo-commons.git] / org.argeo.api.uuid / src / org / argeo / api / uuid / NoOpUuidFactory.java
1 package org.argeo.api.uuid;
2
3 import java.util.UUID;
4
5 /**
6 * An {@link UuidFactory} which does not implement any algorith and returns
7 * {@link UnsupportedOperationException} for methods requiring them. Only
8 * {@link UuidFactory#get()} and {@link UuidFactory#randomUUID()} are
9 * implemented, trivially based on {@link UUID#randomUUID()}. It can be useful
10 * as a base class for partial implementations, or whren only random
11 * {@link UUID}s are needed, but one wants to integrate with this UUID API via
12 * {@link UuidFactory}.
13 */
14 public class NoOpUuidFactory implements UuidFactory {
15 public static final UuidFactory onlyJavaRandom = new NoOpUuidFactory();
16
17 /** Returns {@link #randomUUID()}. */
18 @Override
19 public UUID get() {
20 return randomUUID();
21 }
22
23 /**
24 * Creates a random UUID (v4) with {@link UUID#randomUUID()}.
25 *
26 * @return a random {@link UUID}
27 */
28 @Override
29 public UUID randomUUID() {
30 return UUID.randomUUID();
31 }
32
33 /**
34 * Throws an {@link UnsupportedOperationException}.
35 *
36 * @throws UnsupportedOperationException always
37 */
38 @Override
39 public UUID timeUUID() {
40 throw new UnsupportedOperationException("Time based UUIDs are not implemented");
41 }
42
43 /**
44 * Throws an {@link UnsupportedOperationException}.
45 *
46 * @throws UnsupportedOperationException always
47 */
48 @Override
49 public UUID nameUUIDv5(UUID namespace, byte[] data) {
50 throw new UnsupportedOperationException("Name based UUIDs are not implemented");
51 }
52
53 /**
54 * Throws an {@link UnsupportedOperationException}.
55 *
56 * @throws UnsupportedOperationException always
57 */
58 @Override
59 public UUID nameUUIDv3(UUID namespace, byte[] data) {
60 throw new UnsupportedOperationException("Name based UUIDs are not implemented");
61 }
62
63 /**
64 * Throws an {@link UnsupportedOperationException}.
65 *
66 * @throws UnsupportedOperationException always
67 */
68 @Override
69 public UUID randomUUIDStrong() {
70 throw new UnsupportedOperationException("Strong random UUIDs are not implemented");
71 }
72
73 /**
74 * Throws an {@link UnsupportedOperationException}.
75 *
76 * @throws UnsupportedOperationException always
77 */
78 @Override
79 public UUID randomUUIDWeak() {
80 throw new UnsupportedOperationException("Weak random UUIDs are not implemented");
81 }
82
83 }