public DynamicGenericInfo( @NotNull final DomInvocationHandler handler, final StaticGenericInfo staticGenericInfo) { myInvocationHandler = handler; myStaticGenericInfo = staticGenericInfo; myAttributes = staticGenericInfo.getAttributes(); myFixeds = staticGenericInfo.getFixed(); myCollections = staticGenericInfo.getCollections(); }
private void applyExtensions(DomExtensionsRegistrarImpl registrar) { final List<DomExtensionImpl> fixeds = registrar.getFixeds(); final List<DomExtensionImpl> collections = registrar.getCollections(); final List<DomExtensionImpl> attributes = registrar.getAttributes(); if (!attributes.isEmpty()) { ChildrenDescriptionsHolder<AttributeChildDescriptionImpl> newAttributes = new ChildrenDescriptionsHolder<AttributeChildDescriptionImpl>( myStaticGenericInfo.getAttributes()); for (final DomExtensionImpl extension : attributes) { newAttributes.addDescription( extension.addAnnotations( new AttributeChildDescriptionImpl(extension.getXmlName(), extension.getType()))); } myAttributes = newAttributes; } if (!fixeds.isEmpty()) { ChildrenDescriptionsHolder<FixedChildDescriptionImpl> newFixeds = new ChildrenDescriptionsHolder<FixedChildDescriptionImpl>(myStaticGenericInfo.getFixed()); for (final DomExtensionImpl extension : fixeds) { //noinspection unchecked newFixeds.addDescription( extension.addAnnotations( new FixedChildDescriptionImpl( extension.getXmlName(), extension.getType(), extension.getCount(), ArrayUtil.EMPTY_COLLECTION_ARRAY))); } myFixeds = newFixeds; } if (!collections.isEmpty()) { ChildrenDescriptionsHolder<CollectionChildDescriptionImpl> newCollections = new ChildrenDescriptionsHolder<CollectionChildDescriptionImpl>( myStaticGenericInfo.getCollections()); for (final DomExtensionImpl extension : collections) { newCollections.addDescription( extension.addAnnotations( new CollectionChildDescriptionImpl( extension.getXmlName(), extension.getType(), Collections.<JavaMethod>emptyList()))); } myCollections = newCollections; } final DomExtensionImpl extension = registrar.getCustomChildrenType(); if (extension != null) { myCustomChildren = new CustomDomChildrenDescriptionImpl( null, extension.getType(), extension.getTagNameDescriptor()); } }
public final boolean checkInitialized() { if (myInitialized) return true; myStaticGenericInfo.buildMethodMaps(); if (myComputing.get() == Boolean.TRUE) return false; final XmlElement element = myInvocationHandler.getXmlElement(); if (element == null) return true; myComputing.set(Boolean.TRUE); try { DomExtensionsRegistrarImpl registrar = runDomExtenders(); //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized (element) { if (myInitialized) return true; if (registrar != null) { applyExtensions(registrar); } myInitialized = true; } } finally { myComputing.set(null); } return true; }
@NotNull public List<AbstractDomChildDescriptionImpl> getChildrenDescriptions() { checkInitialized(); final ArrayList<AbstractDomChildDescriptionImpl> list = new ArrayList<AbstractDomChildDescriptionImpl>(); myAttributes.dumpDescriptions(list); myFixeds.dumpDescriptions(list); myCollections.dumpDescriptions(list); ContainerUtil.addIfNotNull(myStaticGenericInfo.getCustomNameChildrenDescription(), list); return list; }
@Override public boolean processAttributeChildrenDescriptions( final Processor<AttributeChildDescriptionImpl> processor) { final Set<AttributeChildDescriptionImpl> visited = new THashSet<AttributeChildDescriptionImpl>(); if (!myStaticGenericInfo.processAttributeChildrenDescriptions( new Processor<AttributeChildDescriptionImpl>() { public boolean process(AttributeChildDescriptionImpl attributeChildDescription) { visited.add(attributeChildDescription); return processor.process(attributeChildDescription); } })) { return false; } for (final AttributeChildDescriptionImpl description : getAttributeChildrenDescriptions()) { if (!visited.contains(description) && !processor.process(description)) { return false; } } return true; }
public Invocation createInvocation(final JavaMethod method) { return myStaticGenericInfo.createInvocation(method); }
public boolean isTagValueElement() { return myStaticGenericInfo.isTagValueElement(); }
public String getElementName(DomElement element) { return myStaticGenericInfo.getElementName(element); }
@Nullable public CustomDomChildrenDescriptionImpl getCustomNameChildrenDescription() { checkInitialized(); if (myCustomChildren != null) return myCustomChildren; return myStaticGenericInfo.getCustomNameChildrenDescription(); }
public GenericDomValue getNameDomElement(DomElement element) { return myStaticGenericInfo.getNameDomElement(element); }
public XmlElement getNameElement(DomElement element) { return myStaticGenericInfo.getNameElement(element); }