BrightSide Workbench Full Report + Source Code
ParserMacroSet.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.parser;
20 
21 import java.util.TreeSet;
22 
27 public class ParserMacroSet extends TreeSet<ParserMacro> {
28 
29  public ParserMacro addMacro(String macroName) {
30  ParserMacro pm = new ParserMacro(macroName, size());
31  add(pm);
32  return pm;
33  }
34 
35  public void copyParametersTo(ParserMacro origin, ParserMacro destiny) {
36  for(ParserParameter parameter : origin.getParameters()) {
37  destiny.addParameter(parameter.getName(), parameter.isOptional(),
38  parameter.getDefaultValue(), parameter.isCommaSeparated());
39  for(String value : parameter.getPossibleValues()) {
40  destiny.addPossibleValue(value);
41  }
42  }
43  }
44 
45  public void addDefaultsFor(String name, ParserMacroSet macros) {
46  addMacro(name + "-summary").copyParametersFrom(name, macros);
47  addMacro(name + "-ranking").copyParametersFrom(name, macros);
48  addMacro(name + "-summary-ranking").copyParametersFrom(name, macros);
49  addMacro(name + "-restricted").copyParametersFrom(name, macros);
50  addMacro(name + "-summary-ranking-restricted").copyParametersFrom(name, macros);
51  addMacro(name + "-ranking-restricted").copyParametersFrom(name, macros);
52  }
53 
54 }
void addDefaultsFor(String name, ParserMacroSet macros)
void copyParametersTo(ParserMacro origin, ParserMacro destiny)
ParserMacro addMacro(String macroName)
ParserMacro addPossibleValue(String value)
void copyParametersFrom(String macroName, ParserMacroSet macros)
TreeSet< ParserParameter > getParameters()
ParserMacro addParameter(String name, boolean optional)