@Test public void produceFor() { AdHoc.adHocProps.clear(); Map<Context, PropFile> existingContexts = new ConcurrentHashMap<Context, PropFile>(1, 1.0f); AdHoc.adHocProps.put(Scope.named("existing"), existingContexts); PropFile existingFile = new PropFile(Context.named("existing"), Scope.named("existing"), PropFile.Loc.AdHoc); existingContexts.put(Context.named("existing"), existingFile); Map<Scope, Map<Context, PropFile>> system = new ConcurrentHashMap<Scope, Map<Context, PropFile>>(); Map<Scope, Map<Context, PropFile>> local = new ConcurrentHashMap<Scope, Map<Context, PropFile>>(); Map<Scope, Map<Context, PropFile>> produced = AdHoc.produceFor(system, local); assertEquals(1, produced.size()); assertEquals(1, AdHoc.adHocProps.size()); assertEquals(1, produced.get(Scope.named("existing")).size()); assertSame(existingFile, produced.get(Scope.named("existing")).get(Context.named("existing"))); Map<Context, PropFile> systemContexts = new ConcurrentHashMap<Context, PropFile>(); Map<Context, PropFile> localContexts = new ConcurrentHashMap<Context, PropFile>(); Map<Context, PropFile> localTestContexts = new ConcurrentHashMap<Context, PropFile>(); system.put(Scope.Default, systemContexts); local.put(Scope.Default, localContexts); local.put(Scope.named("test"), localTestContexts); produced = AdHoc.produceFor(system, local); assertEquals(3, produced.size()); assertEquals(3, AdHoc.adHocProps.size()); assertEquals(0, produced.get(Scope.Default).size()); assertEquals(0, produced.get(Scope.named("test")).size()); assertEquals(1, produced.get(Scope.named("existing")).size()); assertEquals(0, AdHoc.adHocProps.get(Scope.Default).size()); assertEquals(0, AdHoc.adHocProps.get(Scope.named("test")).size()); systemContexts.put(Context.named("foo"), new PropFile(Context.named("foo"), PropFile.Loc.System)); localContexts.put(Context.named("bar"), new PropFile(Context.named("bar"), PropFile.Loc.Local)); localContexts.put(Context.named("foo"), new PropFile(Context.named("foo"), PropFile.Loc.Local)); localTestContexts.put(Context.named("foobar"), new PropFile(Context.named("foobar"), Scope.named("test"), PropFile.Loc.Local)); produced = AdHoc.produceFor(system, local); assertEquals(3, produced.size()); assertEquals(3, AdHoc.adHocProps.size()); assertEquals(2, produced.get(Scope.Default).size()); assertEquals(1, produced.get(Scope.named("test")).size()); assertEquals(1, produced.get(Scope.named("existing")).size()); assertEquals(2, AdHoc.adHocProps.get(Scope.Default).size()); assertEquals(1, AdHoc.adHocProps.get(Scope.named("test")).size()); assertEquals(1, AdHoc.adHocProps.get(Scope.named("existing")).size()); assertSame(AdHoc.adHocProps.get(Scope.Default).get(Context.named("foo")), produced.get(Scope.Default).get(Context.named("foo"))); assertSame(AdHoc.adHocProps.get(Scope.Default).get(Context.named("bar")), produced.get(Scope.Default).get(Context.named("bar"))); assertSame(AdHoc.adHocProps.get(Scope.named("test")).get(Context.named("foobar")), produced.get(Scope.named("test")).get(Context.named("foobar"))); assertSame(existingFile, produced.get(Scope.named("existing")).get(Context.named("existing"))); }
static Map<Scope, Map<Context, PropFile>> produceFor(Map<Scope, Map<Context, PropFile>> system, Map<Scope, Map<Context, PropFile>> local) { Map<Scope, Map<Context, PropFile>> adHocPropFiles = new ConcurrentHashMap<Scope, Map<Context, PropFile>>(3, 1.0f); for (Scope scope : system.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = new ConcurrentHashMap<Context, PropFile>(13,1.0f); adHocPropFiles.put(scope, adHocContexts); Map<Context, PropFile> contexts = system.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } adHocContexts.put(context, adHocPropFile); } } for (Scope scope : local.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = adHocPropFiles.get(scope); if (adHocContexts == null) { adHocContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocPropFiles.put(scope, adHocContexts); } Map<Context, PropFile> contexts = local.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } if (!adHocContexts.containsKey(context)) { adHocContexts.put(context, adHocPropFile); } } } for (Scope scope : adHocProps.keySet()) { Map<Context, PropFile> contexts = adHocPropFiles.get(scope); if (contexts == null) { contexts = new ConcurrentHashMap<Context, PropFile>(12, 1.0f); adHocPropFiles.put(scope, contexts); } Map<Context, PropFile> existing = adHocProps.get(scope); for (Context context : existing.keySet()) { if (!contexts.containsKey(context)) { contexts.put(context, existing.get(context)); } } } return adHocPropFiles; }
AdHoc { static Map<Scope, Map<Context, PropFile>> produceFor(Map<Scope, Map<Context, PropFile>> system, Map<Scope, Map<Context, PropFile>> local) { Map<Scope, Map<Context, PropFile>> adHocPropFiles = new ConcurrentHashMap<Scope, Map<Context, PropFile>>(3, 1.0f); for (Scope scope : system.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = new ConcurrentHashMap<Context, PropFile>(13,1.0f); adHocPropFiles.put(scope, adHocContexts); Map<Context, PropFile> contexts = system.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } adHocContexts.put(context, adHocPropFile); } } for (Scope scope : local.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = adHocPropFiles.get(scope); if (adHocContexts == null) { adHocContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocPropFiles.put(scope, adHocContexts); } Map<Context, PropFile> contexts = local.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } if (!adHocContexts.containsKey(context)) { adHocContexts.put(context, adHocPropFile); } } } for (Scope scope : adHocProps.keySet()) { Map<Context, PropFile> contexts = adHocPropFiles.get(scope); if (contexts == null) { contexts = new ConcurrentHashMap<Context, PropFile>(12, 1.0f); adHocPropFiles.put(scope, contexts); } Map<Context, PropFile> existing = adHocProps.get(scope); for (Context context : existing.keySet()) { if (!contexts.containsKey(context)) { contexts.put(context, existing.get(context)); } } } return adHocPropFiles; } }
AdHoc { static Map<Scope, Map<Context, PropFile>> produceFor(Map<Scope, Map<Context, PropFile>> system, Map<Scope, Map<Context, PropFile>> local) { Map<Scope, Map<Context, PropFile>> adHocPropFiles = new ConcurrentHashMap<Scope, Map<Context, PropFile>>(3, 1.0f); for (Scope scope : system.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = new ConcurrentHashMap<Context, PropFile>(13,1.0f); adHocPropFiles.put(scope, adHocContexts); Map<Context, PropFile> contexts = system.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } adHocContexts.put(context, adHocPropFile); } } for (Scope scope : local.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = adHocPropFiles.get(scope); if (adHocContexts == null) { adHocContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocPropFiles.put(scope, adHocContexts); } Map<Context, PropFile> contexts = local.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } if (!adHocContexts.containsKey(context)) { adHocContexts.put(context, adHocPropFile); } } } for (Scope scope : adHocProps.keySet()) { Map<Context, PropFile> contexts = adHocPropFiles.get(scope); if (contexts == null) { contexts = new ConcurrentHashMap<Context, PropFile>(12, 1.0f); adHocPropFiles.put(scope, contexts); } Map<Context, PropFile> existing = adHocProps.get(scope); for (Context context : existing.keySet()) { if (!contexts.containsKey(context)) { contexts.put(context, existing.get(context)); } } } return adHocPropFiles; }  }
AdHoc { static Map<Scope, Map<Context, PropFile>> produceFor(Map<Scope, Map<Context, PropFile>> system, Map<Scope, Map<Context, PropFile>> local) { Map<Scope, Map<Context, PropFile>> adHocPropFiles = new ConcurrentHashMap<Scope, Map<Context, PropFile>>(3, 1.0f); for (Scope scope : system.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = new ConcurrentHashMap<Context, PropFile>(13,1.0f); adHocPropFiles.put(scope, adHocContexts); Map<Context, PropFile> contexts = system.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } adHocContexts.put(context, adHocPropFile); } } for (Scope scope : local.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = adHocPropFiles.get(scope); if (adHocContexts == null) { adHocContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocPropFiles.put(scope, adHocContexts); } Map<Context, PropFile> contexts = local.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } if (!adHocContexts.containsKey(context)) { adHocContexts.put(context, adHocPropFile); } } } for (Scope scope : adHocProps.keySet()) { Map<Context, PropFile> contexts = adHocPropFiles.get(scope); if (contexts == null) { contexts = new ConcurrentHashMap<Context, PropFile>(12, 1.0f); adHocPropFiles.put(scope, contexts); } Map<Context, PropFile> existing = adHocProps.get(scope); for (Context context : existing.keySet()) { if (!contexts.containsKey(context)) { contexts.put(context, existing.get(context)); } } } return adHocPropFiles; }  static void add(List<String> adHocProps); static Map<Scope, Map<Context, PropFile>> get(); }
AdHoc { static Map<Scope, Map<Context, PropFile>> produceFor(Map<Scope, Map<Context, PropFile>> system, Map<Scope, Map<Context, PropFile>> local) { Map<Scope, Map<Context, PropFile>> adHocPropFiles = new ConcurrentHashMap<Scope, Map<Context, PropFile>>(3, 1.0f); for (Scope scope : system.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = new ConcurrentHashMap<Context, PropFile>(13,1.0f); adHocPropFiles.put(scope, adHocContexts); Map<Context, PropFile> contexts = system.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } adHocContexts.put(context, adHocPropFile); } } for (Scope scope : local.keySet()) { Map<Context, PropFile> existingContexts = adHocProps.get(scope); if (existingContexts == null) { existingContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocProps.put(scope, existingContexts); } Map<Context, PropFile> adHocContexts = adHocPropFiles.get(scope); if (adHocContexts == null) { adHocContexts = new ConcurrentHashMap<Context, PropFile>(13, 1.0f); adHocPropFiles.put(scope, adHocContexts); } Map<Context, PropFile> contexts = local.get(scope); for (Context context : contexts.keySet()) { PropFile adHocPropFile = existingContexts.get(context); if (adHocPropFile == null) { adHocPropFile = new PropFile(context, scope, PropFile.Loc.AdHoc); existingContexts.put(context, adHocPropFile); } if (!adHocContexts.containsKey(context)) { adHocContexts.put(context, adHocPropFile); } } } for (Scope scope : adHocProps.keySet()) { Map<Context, PropFile> contexts = adHocPropFiles.get(scope); if (contexts == null) { contexts = new ConcurrentHashMap<Context, PropFile>(12, 1.0f); adHocPropFiles.put(scope, contexts); } Map<Context, PropFile> existing = adHocProps.get(scope); for (Context context : existing.keySet()) { if (!contexts.containsKey(context)) { contexts.put(context, existing.get(context)); } } } return adHocPropFiles; }  static void add(List<String> adHocProps); static Map<Scope, Map<Context, PropFile>> get();  }