@Test public void testGetGroups() { TestPropertyRegistrarLoader loader = new TestPropertyRegistrarLoader(); List<GroupProxy> groups = loader.getGroups(); assertEquals(2, groups.size()); assertEquals(PropertyRegistrarLoaderTest.class.getCanonicalName(), groups.get(0).getCanonicalName()); assertEquals(PropertyRegistrarLoaderTest.class.getCanonicalName() + "$InnerClass", groups.get(1).getJavaCanonicalName()); assertEquals(1, groups.get(0).getProperties().size()); assertEquals("MY_PROP1", groups.get(0).getProperties().get(0).fieldName); assertTrue(MY_PROP1 == groups.get(0).getProperties().get(0).property); assertEquals(2, groups.get(1).getProperties().size()); assertEquals("MY_PROP2", groups.get(1).getProperties().get(0).fieldName); assertTrue(InnerClass.MY_PROP2 == groups.get(1).getProperties().get(0).property); assertEquals("MY_PROP3", groups.get(1).getProperties().get(1).fieldName); assertTrue(InnerClass.MY_PROP3 == groups.get(1).getProperties().get(1).property); }
public List<GroupProxy> getGroups() { LinkedHashMap <String, GroupProxyMutable> groups = new LinkedHashMap(); List<PropertyRegistrar> registrars = getPropertyRegistrars(); for (PropertyRegistrar registrar : registrars) { for (PropertyRegistration registration : registrar.getRegistrationList()) { String grpName = registration.getCanonicalParentName(); GroupProxyMutable grp = groups.get(grpName); if (grp == null) { grp = new GroupProxyMutable(registration.getCanonicalParentName(), registration.getJavaCanonicalParentName()); groups.put(grpName, grp); } Class<?> group = null; Property prop = null; try { group = Class.forName(registration.getJavaCanonicalParentName()); Field f = group.getDeclaredField(registration.getPropertyName()); try { prop = (Property) f.get(null); } catch (Exception ex) { f.setAccessible(true); prop = (Property) f.get(null); } } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } catch (NoSuchFieldException | IllegalAccessException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (SecurityException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (IllegalArgumentException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } NameAndProperty nap = new NameAndProperty(registration.getPropertyName(), prop); grp.addProperty(nap); } } List<GroupProxy> list = new ArrayList(); list.addAll(groups.values()); return list; }
PropertyRegistrarLoader { public List<GroupProxy> getGroups() { LinkedHashMap <String, GroupProxyMutable> groups = new LinkedHashMap(); List<PropertyRegistrar> registrars = getPropertyRegistrars(); for (PropertyRegistrar registrar : registrars) { for (PropertyRegistration registration : registrar.getRegistrationList()) { String grpName = registration.getCanonicalParentName(); GroupProxyMutable grp = groups.get(grpName); if (grp == null) { grp = new GroupProxyMutable(registration.getCanonicalParentName(), registration.getJavaCanonicalParentName()); groups.put(grpName, grp); } Class<?> group = null; Property prop = null; try { group = Class.forName(registration.getJavaCanonicalParentName()); Field f = group.getDeclaredField(registration.getPropertyName()); try { prop = (Property) f.get(null); } catch (Exception ex) { f.setAccessible(true); prop = (Property) f.get(null); } } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } catch (NoSuchFieldException | IllegalAccessException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (SecurityException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (IllegalArgumentException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } NameAndProperty nap = new NameAndProperty(registration.getPropertyName(), prop); grp.addProperty(nap); } } List<GroupProxy> list = new ArrayList(); list.addAll(groups.values()); return list; } }
PropertyRegistrarLoader { public List<GroupProxy> getGroups() { LinkedHashMap <String, GroupProxyMutable> groups = new LinkedHashMap(); List<PropertyRegistrar> registrars = getPropertyRegistrars(); for (PropertyRegistrar registrar : registrars) { for (PropertyRegistration registration : registrar.getRegistrationList()) { String grpName = registration.getCanonicalParentName(); GroupProxyMutable grp = groups.get(grpName); if (grp == null) { grp = new GroupProxyMutable(registration.getCanonicalParentName(), registration.getJavaCanonicalParentName()); groups.put(grpName, grp); } Class<?> group = null; Property prop = null; try { group = Class.forName(registration.getJavaCanonicalParentName()); Field f = group.getDeclaredField(registration.getPropertyName()); try { prop = (Property) f.get(null); } catch (Exception ex) { f.setAccessible(true); prop = (Property) f.get(null); } } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } catch (NoSuchFieldException | IllegalAccessException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (SecurityException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (IllegalArgumentException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } NameAndProperty nap = new NameAndProperty(registration.getPropertyName(), prop); grp.addProperty(nap); } } List<GroupProxy> list = new ArrayList(); list.addAll(groups.values()); return list; } PropertyRegistrarLoader();  PropertyRegistrarLoader(ClassLoader classLoader); }
PropertyRegistrarLoader { public List<GroupProxy> getGroups() { LinkedHashMap <String, GroupProxyMutable> groups = new LinkedHashMap(); List<PropertyRegistrar> registrars = getPropertyRegistrars(); for (PropertyRegistrar registrar : registrars) { for (PropertyRegistration registration : registrar.getRegistrationList()) { String grpName = registration.getCanonicalParentName(); GroupProxyMutable grp = groups.get(grpName); if (grp == null) { grp = new GroupProxyMutable(registration.getCanonicalParentName(), registration.getJavaCanonicalParentName()); groups.put(grpName, grp); } Class<?> group = null; Property prop = null; try { group = Class.forName(registration.getJavaCanonicalParentName()); Field f = group.getDeclaredField(registration.getPropertyName()); try { prop = (Property) f.get(null); } catch (Exception ex) { f.setAccessible(true); prop = (Property) f.get(null); } } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } catch (NoSuchFieldException | IllegalAccessException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (SecurityException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (IllegalArgumentException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } NameAndProperty nap = new NameAndProperty(registration.getPropertyName(), prop); grp.addProperty(nap); } } List<GroupProxy> list = new ArrayList(); list.addAll(groups.values()); return list; } PropertyRegistrarLoader();  PropertyRegistrarLoader(ClassLoader classLoader); List<PropertyRegistrar> getPropertyRegistrars(); List<GroupProxy> getGroups(); }
PropertyRegistrarLoader { public List<GroupProxy> getGroups() { LinkedHashMap <String, GroupProxyMutable> groups = new LinkedHashMap(); List<PropertyRegistrar> registrars = getPropertyRegistrars(); for (PropertyRegistrar registrar : registrars) { for (PropertyRegistration registration : registrar.getRegistrationList()) { String grpName = registration.getCanonicalParentName(); GroupProxyMutable grp = groups.get(grpName); if (grp == null) { grp = new GroupProxyMutable(registration.getCanonicalParentName(), registration.getJavaCanonicalParentName()); groups.put(grpName, grp); } Class<?> group = null; Property prop = null; try { group = Class.forName(registration.getJavaCanonicalParentName()); Field f = group.getDeclaredField(registration.getPropertyName()); try { prop = (Property) f.get(null); } catch (Exception ex) { f.setAccessible(true); prop = (Property) f.get(null); } } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } catch (NoSuchFieldException | IllegalAccessException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (SecurityException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } catch (IllegalArgumentException ex) { Logger.getLogger(PropertyRegistrarLoader.class.getName()).log(Level.SEVERE, null, ex); continue; } NameAndProperty nap = new NameAndProperty(registration.getPropertyName(), prop); grp.addProperty(nap); } } List<GroupProxy> list = new ArrayList(); list.addAll(groups.values()); return list; } PropertyRegistrarLoader();  PropertyRegistrarLoader(ClassLoader classLoader); List<PropertyRegistrar> getPropertyRegistrars(); List<GroupProxy> getGroups();  }