Gridarta Editor
Spec.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 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 General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.textedit.textarea.tokenmarker;
21 
22 import java.util.HashMap;
23 import java.util.Map;
24 
29 public class Spec {
30 
34  private final byte id;
35 
39  private final Map<String, Parameter> parameters = new HashMap<>();
40 
46  public Spec(final byte id, final Parameter... parameters) {
47  this.id = id;
48  for (final Parameter parameter : parameters) {
49  if (this.parameters.put(parameter.getName(), parameter) != null) {
50  throw new IllegalArgumentException("duplicate parameter name: " + parameter.getName());
51  }
52  }
53  }
54 
59  public byte getId() {
60  return id;
61  }
62 
69  public Parameter getParameter(final String name) {
70  return parameters.get(name);
71  }
72 
73 }
name
name
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:2
net.sf.gridarta.textedit.textarea.tokenmarker.Spec.getId
byte getId()
Returns the token id used to highlight this command.
Definition: Spec.java:59
net.sf.gridarta.textedit.textarea.tokenmarker.Spec.parameters
final Map< String, Parameter > parameters
Maps parameter name to parameter specification.
Definition: Spec.java:39
net.sf.gridarta.textedit.textarea.tokenmarker.Parameter
Describes a parameter.
Definition: Parameter.java:26
net.sf.gridarta.textedit.textarea.tokenmarker.Spec.getParameter
Parameter getParameter(final String name)
Returns the parameter specification for a parameter name.
Definition: Spec.java:69
net.sf.gridarta.textedit.textarea.tokenmarker.Spec
Describes a command (excluding the command name).
Definition: Spec.java:29
net.sf.gridarta.textedit.textarea.tokenmarker.Spec.id
final byte id
The token id used to highlight this command.
Definition: Spec.java:34
net.sf.gridarta.textedit.textarea.tokenmarker.Spec.Spec
Spec(final byte id, final Parameter... parameters)
Creates a new instance.
Definition: Spec.java:46