def._addSetter(setter, method); def._addGetter(getter, method); def._addFactoryParameter(parameter, method);
/** * Returns true if this component may contain children. * * @return True if this component may contain children. */ public boolean isContainer() { return componentDefinition.childrenAllowed(); }
if (def.getTag().startsWith("#")) { continue; Element ele = createElement("element", root, "name", def.getTag()); Element ct = createElement("complexType", ele); boolean childrenAllowed = def.childrenAllowed(); boolean contentAllowed = def.contentHandling() != ContentHandling.ERROR; for (Entry<String, Cardinality> childTag : def.getChildTags().entrySet()) { String tag = childTag.getKey(); Cardinality card = childTag.getValue(); processAttributes(def.getSetters(), ct); processAttributes(def.getFactoryParameters(), ct);
public void validateChild(ComponentDefinition childDefinition, IntSupplier childCount) { if (!childrenAllowed()) { throw new ComponentException(componentClass, "Children are not allowed"); } childDefinition.validateParent(this); Cardinality cardinality = getCardinality(childDefinition.tag); if (cardinality == null) { throw new ComponentException(componentClass, "%s is not a valid child", childDefinition.componentClass); } if (cardinality.hasMaximum() && childCount.getAsInt() >= cardinality.getMaximum()) { throw new ComponentException(componentClass, "A maximum of %d children of type %s are allowed", cardinality.getMaximum(), childDefinition.componentClass); } }
/** * Creates and registers a component definition for a class by scanning the class and its * superclasses for method annotations. * * @param clazz Class to scan. */ @Override protected void doScanClass(Class<BaseComponent> clazz) { if (log.isDebugEnabled()) { log.debug("Processing @Component annotation for class " + clazz); } ComponentDefinition def = new ComponentDefinition(clazz); scanMethods(def, clazz, false); scanMethods(def, def.getFactoryClass(), true); ComponentRegistry.getInstance().register(def); }
Map<String, Cardinality> map = new HashMap<>(getDefinition().getChildTags()); map.remove("*"); int count = child.getValue(); String tag = child.getKey(); Cardinality cardinality = getDefinition().getCardinality(tag); map.remove(tag);
/** * Creates a component definition derived from annotation information within the specified * class. * * @param componentClass A component class. */ public ComponentDefinition(Class<? extends BaseComponent> componentClass) { Component annot = componentClass.getAnnotation(Component.class); this.componentClass = componentClass; this.factoryClass = annot.factoryClass(); this.widgetModule = annot.widgetModule(); this.widgetClass = annot.widgetClass(); this.tag = annot.tag(); this.contentHandling = annot.content(); for (String tag : annot.parentTag()) { addParentTag(tag); } for (ChildTag tag : annot.childTag()) { addChildTag(tag); } }
switch (parentDef.contentHandling()) { case ERROR: throw new RuntimeException("Text content is not allowed for tag " + parentDef.getTag());