/** * Sets the configurable class of this object. * * @throws RuntimeException if the the <code>Configurable</code> is already instantiated. */ void setConfigurableClass(Class<? extends Configurable> confClass) { ownerClass = confClass; // Don't allow changes of the class if the configurable has already been instantiated if (isInstanciated()) throw new RuntimeException("class is already instantiated"); // clean up the properties if necessary // registeredProperties.clear(); final Collection<String> classProperties = new HashSet<String>(); final Map<Field, Annotation> classProps = parseClass(ownerClass); for (Map.Entry<Field, Annotation> entry : classProps.entrySet()) { try { String propertyName = (String) entry.getKey().get(null); // make sure that there is not already another property with this name assert !classProperties.contains(propertyName) : "duplicate property-name for different properties: " + propertyName + " for the class " + confClass; registerProperty(propertyName, new S4PropWrapper(entry.getValue())); classProperties.add(propertyName); } catch (IllegalAccessException e) { e.printStackTrace(); } } }