1 package com.github.javaparser.version; 2 3 import com.github.javaparser.ParseResult; 4 import com.github.javaparser.ParserConfiguration; 5 import com.github.javaparser.ast.Node; 6 7 import java.util.ArrayList; 8 import java.util.Arrays; 9 import java.util.List; 10 11 import static com.github.javaparser.ParseResult.PostProcessor; 12 13 /** 14 * A post processor that will call a collection of post processors. 15 */ 16 public class PostProcessors implements PostProcessor { 17 private final List<PostProcessor> postProcessors = new ArrayList<>(); 18 19 public PostProcessors(PostProcessor... postProcessors) { 20 this.postProcessors.addAll(Arrays.asList(postProcessors)); 21 } 22 23 public List<PostProcessor> getPostProcessors() { 24 return postProcessors; 25 } 26 27 public PostProcessors remove(PostProcessor postProcessor) { 28 if (!postProcessors.remove(postProcessor)) { 29 throw new AssertionError("Trying to remove a post processor that isn't there."); 30 } 31 return this; 32 } 33 34 public PostProcessors replace(PostProcessor oldProcessor, PostProcessor newProcessor) { 35 remove(oldProcessor); 36 add(newProcessor); 37 return this; 38 } 39 40 public PostProcessors add(PostProcessor newProcessor) { 41 postProcessors.add(newProcessor); 42 return this; 43 } 44 45 @Override 46 public void process(ParseResult<? extends Node> result, ParserConfiguration configuration) { 47 postProcessors.forEach(pp -> pp.process(result, configuration)); 48 } 49 } 50