Crossfire JXClient, Trunk
StartingMapBuilder.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff
19  * Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.server.crossfire;
24 
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.Collections;
29 import org.jetbrains.annotations.NotNull;
30 import org.jetbrains.annotations.Nullable;
31 
37 public class StartingMapBuilder {
38 
43  @Nullable
44  private String archName;
45 
50  @Nullable
51  private String name;
52 
57  @Nullable
58  private String description;
59 
63  @NotNull
64  private final Collection<StartingMap> startingMaps = new ArrayList<>();
65 
70  public void setArchName(@NotNull final String archName) {
72  this.archName = archName;
73  name = null;
74  description = null;
75  }
76 
81  public void setName(@NotNull final String name) {
82  if (archName == null) {
83  System.err.println("missing archetype name for name '"+name+"' in startingmap block");
84  return;
85  }
86  if (this.name != null) {
87  System.err.println("duplicate name '"+name+"' in startingmap block; previous name was '"+this.name+"'");
88  return;
89  }
90  this.name = name;
91  }
92 
97  public void setDescription(@NotNull final String description) {
98  if (archName == null) {
99  System.err.println("missing archetype name for description '"+description+"' in startingmap block");
100  return;
101  }
102  if (this.description != null) {
103  System.err.println("duplicate description '"+description+"' in startingmap block; previous description was '"+this.description+"'");
104  return;
105  }
106  this.description = description;
107  }
108 
113  @NotNull
114  public Collection<StartingMap> finish() {
115  addStartingMap();
116  return Collections.unmodifiableCollection(startingMaps);
117  }
118 
123  private void addStartingMap() {
124  if (archName == null) {
125  return;
126  }
127 
128  startingMaps.add(new StartingMap(archName, name == null ? "" : name, description == null ? "" : description));
129  archName = null;
130  name = null;
131  description = null;
132  }
133 
134 }
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.setArchName
void setArchName(@NotNull final String archName)
Definition: StartingMapBuilder.java:70
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.setDescription
void setDescription(@NotNull final String description)
Definition: StartingMapBuilder.java:97
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.archName
String archName
Definition: StartingMapBuilder.java:44
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder
Definition: StartingMapBuilder.java:37
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.setName
void setName(@NotNull final String name)
Definition: StartingMapBuilder.java:81
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.addStartingMap
void addStartingMap()
Definition: StartingMapBuilder.java:123
com.realtime.crossfire.jxclient.character.StartingMap
Definition: StartingMap.java:31
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.finish
Collection< StartingMap > finish()
Definition: StartingMapBuilder.java:114
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.name
String name
Definition: StartingMapBuilder.java:51
com.realtime.crossfire
com.realtime
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.description
String description
Definition: StartingMapBuilder.java:58
com
com.realtime.crossfire.jxclient.character
Definition: Choice.java:23
com.realtime.crossfire.jxclient.server.crossfire.StartingMapBuilder.startingMaps
final Collection< StartingMap > startingMaps
Definition: StartingMapBuilder.java:64