JavaParser Source Viewer

Home|JavaParser/com/github/javaparser/version/PostProcessors.java
1/*
2 * Copyright (C) 2007-2010 JĂșlio Vilmar Gesser.
3 * Copyright (C) 2011, 2013-2020 The JavaParser Team.
4 *
5 * This file is part of JavaParser.
6 *
7 * JavaParser can be used either under the terms of
8 * a) the GNU Lesser General Public License as published by
9 *     the Free Software Foundation, either version 3 of the License, or
10 *     (at your option) any later version.
11 * b) the terms of the Apache License
12 *
13 * You should have received a copy of both licenses in LICENCE.LGPL and
14 * LICENCE.APACHE. Please refer to those files for details.
15 *
16 * JavaParser is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU Lesser General Public License for more details.
20 */
21
22package com.github.javaparser.version;
23
24import com.github.javaparser.ParseResult;
25import com.github.javaparser.ParserConfiguration;
26import com.github.javaparser.ast.Node;
27
28import java.util.ArrayList;
29import java.util.Arrays;
30import java.util.List;
31
32import static com.github.javaparser.ParseResult.PostProcessor;
33
34/**
35 * A post processor that will call a collection of post processors.
36 */
37public class PostProcessors implements PostProcessor {
38    private final List<PostProcessorpostProcessors = new ArrayList<>();
39
40    public PostProcessors(PostProcessor... postProcessors) {
41        this.postProcessors.addAll(Arrays.asList(postProcessors));
42    }
43
44    public List<PostProcessorgetPostProcessors() {
45        return postProcessors;
46    }
47
48    public PostProcessors remove(PostProcessor postProcessor) {
49        if (!postProcessors.remove(postProcessor)) {
50            throw new AssertionError("Trying to remove a post processor that isn't there.");
51        }
52        return this;
53    }
54
55    public PostProcessors replace(PostProcessor oldProcessorPostProcessor newProcessor) {
56        remove(oldProcessor);
57        add(newProcessor);
58        return this;
59    }
60
61    public PostProcessors add(PostProcessor newProcessor) {
62        postProcessors.add(newProcessor);
63        return this;
64    }
65
66    @Override
67    public void process(ParseResult<? extends NoderesultParserConfiguration configuration) {
68        postProcessors.forEach(pp -> pp.process(resultconfiguration));
69    }
70}
71
MembersX
PostProcessors:add
PostProcessors:getPostProcessors
PostProcessors:PostProcessors
PostProcessors:replace
PostProcessors:remove
PostProcessors:process
PostProcessors:postProcessors
Members
X