コード例 #1
0
 @NotNull
 private static <S> PackagingElement<S> copyElement(
     @NotNull PackagingElement<S> element, @NotNull Project project) {
   //noinspection unchecked
   final PackagingElement<S> copy = (PackagingElement<S>) element.getType().createEmpty(project);
   copy.loadState(element.getState());
   return copy;
 }
コード例 #2
0
 private static Element serializePackagingElement(PackagingElement<?> packagingElement) {
   Element element = new Element(PACKAGING_ELEMENT_NAME);
   element.setAttribute(TYPE_ID_ATTRIBUTE, packagingElement.getType().getId());
   final Object bean = packagingElement.getState();
   if (bean != null) {
     XmlSerializer.serializeInto(bean, element, new SkipDefaultValuesSerializationFilters());
   }
   if (packagingElement instanceof CompositePackagingElement) {
     for (PackagingElement<?> child :
         ((CompositePackagingElement<?>) packagingElement).getChildren()) {
       element.addContent(serializePackagingElement(child));
     }
   }
   return element;
 }
コード例 #3
0
 private static <E extends PackagingElement<?>> boolean processElementRecursively(
     @NotNull PackagingElement<?> element,
     @Nullable PackagingElementType<E> type,
     @NotNull PackagingElementProcessor<? super E> processor,
     @NotNull PackagingElementResolvingContext resolvingContext,
     final boolean processSubstitutions,
     ArtifactType artifactType,
     @NotNull PackagingElementPath path,
     Set<PackagingElement<?>> processed) {
   if (!processor.shouldProcess(element) || !processed.add(element)) {
     return true;
   }
   if (type == null || element.getType().equals(type)) {
     if (!processor.process((E) element, path)) {
       return false;
     }
   }
   if (element instanceof CompositePackagingElement<?>) {
     final CompositePackagingElement<?> composite = (CompositePackagingElement<?>) element;
     return processElementsRecursively(
         composite.getChildren(),
         type,
         processor,
         resolvingContext,
         processSubstitutions,
         artifactType,
         path.appendComposite(composite),
         processed);
   } else if (element instanceof ComplexPackagingElement<?> && processSubstitutions) {
     final ComplexPackagingElement<?> complexElement = (ComplexPackagingElement<?>) element;
     if (processor.shouldProcessSubstitution(complexElement)) {
       final List<? extends PackagingElement<?>> substitution =
           complexElement.getSubstitution(resolvingContext, artifactType);
       if (substitution != null) {
         return processElementsRecursively(
             substitution,
             type,
             processor,
             resolvingContext,
             processSubstitutions,
             artifactType,
             path.appendComplex(complexElement),
             processed);
       }
     }
   }
   return true;
 }