1 package org
.argeo
.init
.prefs
;
3 import java
.util
.concurrent
.CompletableFuture
;
4 import java
.util
.concurrent
.ExecutionException
;
5 import java
.util
.prefs
.Preferences
;
6 import java
.util
.prefs
.PreferencesFactory
;
8 public class ThinPreferencesFactory
implements PreferencesFactory
{
9 private static CompletableFuture
<ThinPreferencesFactory
> INSTANCE
= new CompletableFuture
<>();
11 private SystemRootPreferences systemRootPreferences
;
13 public ThinPreferencesFactory() {
14 systemRootPreferences
= new SystemRootPreferences();
15 if (INSTANCE
.isDone())
16 throw new IllegalStateException(
17 "There is already a " + ThinPreferencesFactory
.class.getName() + " instance.");
18 INSTANCE
.complete(this);
22 public Preferences
systemRoot() {
23 return systemRootPreferences
;
27 public Preferences
userRoot() {
28 throw new UnsupportedOperationException();
31 public SystemRootPreferences
getSystemRootPreferences() {
32 return systemRootPreferences
;
35 public static ThinPreferencesFactory
getInstance() {
37 return INSTANCE
.get();
38 } catch (InterruptedException
| ExecutionException e
) {
39 throw new IllegalStateException("Cannot get " + ThinPreferencesFactory
.class.getName() + " instance.", e
);