File tree Expand file tree Collapse file tree
common/src/main/java/de/bluecolored/bluemap/common/debug
core/src/main/java/de/bluecolored/bluemap/core/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import com .google .gson .stream .JsonWriter ;
3030import de .bluecolored .bluemap .core .BlueMap ;
3131import de .bluecolored .bluemap .core .util .Key ;
32+ import de .bluecolored .bluemap .core .util .Registry ;
3233import lombok .SneakyThrows ;
3334
3435import java .io .IOException ;
@@ -64,6 +65,12 @@ public void dump(Path file) throws IOException {
6465
6566 Set <Object > alreadyDumped = Collections .newSetFromMap (new IdentityHashMap <>());
6667
68+ writer .name ("registries" ).beginArray ();
69+ for (Object instance : Registry .REGISTRIES ) {
70+ dumpInstance (instance , writer , alreadyDumped );
71+ }
72+ writer .endArray ();
73+
6774 writer .name ("dump" ).beginArray ();
6875 for (Object instance : instances ) {
6976 dumpInstance (instance , writer , alreadyDumped );
Original file line number Diff line number Diff line change 3333@ NoArgsConstructor
3434public class Registry <T extends Keyed > {
3535
36+ public static final Set <Registry <?>> REGISTRIES = Collections .synchronizedSet (Collections .newSetFromMap (new WeakHashMap <>()));
37+
3638 private final ConcurrentHashMap <Key , T > entries = new ConcurrentHashMap <>();
3739
3840 private final Set <Key > keys = Collections .unmodifiableSet (entries .keySet ());
3941 private final Collection <T > values = Collections .unmodifiableCollection (entries .values ());
4042
4143 @ SafeVarargs
4244 public Registry (T ... defaultEntries ) {
45+ REGISTRIES .add (this );
46+
4347 for (T entry : defaultEntries )
4448 register (entry );
4549 }
You can’t perform that action at this time.
0 commit comments