Gridarta Editor
Connection.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.gui.panel.connectionview;
21 
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.Iterator;
25 import java.util.List;
27 import org.jetbrains.annotations.NotNull;
28 
34 public class Connection<K> implements Iterable<GameObject<?, ?, ?>> {
35 
39  @NotNull
40  private final K key;
41 
48  @NotNull
49  private final List<GameObject<?, ?, ?>> gameObjects = new ArrayList<>(2);
50 
55  public Connection(@NotNull final K key) {
56  this.key = key;
57  }
58 
63  @NotNull
64  public K getKey() {
65  return key;
66  }
67 
72  public void addGameObject(@NotNull final GameObject<?, ?, ?> gameObject) {
73  if (!gameObjects.contains(gameObject)) {
74  gameObjects.add(gameObject);
75  }
76  }
77 
78  @NotNull
79  @Override
80  public Iterator<GameObject<?, ?, ?>> iterator() {
81  return Collections.unmodifiableList(gameObjects).iterator();
82  }
83 
84 }
net.sf.gridarta.gui.panel.connectionview.Connection.iterator
Iterator< GameObject<?, ?, ?> > iterator()
Definition: Connection.java:80
net.sf.gridarta
Base package of all Gridarta classes.
net.sf
net.sf.gridarta.gui.panel.connectionview.Connection.key
final K key
The key.
Definition: Connection.java:40
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.gui.panel.connectionview.Connection.Connection
Connection(@NotNull final K key)
Creates a new instance.
Definition: Connection.java:55
net.sf.gridarta.gui.panel.connectionview.Connection.getKey
K getKey()
Returns the key.
Definition: Connection.java:64
net.sf.gridarta.model
net.sf.gridarta.gui.panel.connectionview.Connection
Stores GameObjects related to key values.
Definition: Connection.java:34
net.sf.gridarta.var.crossfire.model.gameobject.GameObject<?, ?, ?>
net.sf.gridarta.gui.panel.connectionview.Connection.addGameObject
void addGameObject(@NotNull final GameObject<?, ?, ?> gameObject)
Adds a game object.
Definition: Connection.java:72
net.sf.gridarta.gui.panel.connectionview.Connection.gameObjects
final List< GameObject<?, ?, ?> > gameObjects
The game objects for this connection.
Definition: Connection.java:49