Gridarta Editor
NotInsideContainerException.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 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.model.gameobject;
21 
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
26 
34 public class NotInsideContainerException extends IllegalStateException {
35 
39  private static final long serialVersionUID = 1L;
40 
46  @Nullable
48 
54  @NotNull
56 
62  public NotInsideContainerException(@NotNull final GameObject<?, ?, ?> item) {
63  this(null, item);
64  }
65 
73  public NotInsideContainerException(@Nullable final GameObjectContainer<?, ?, ?> container, @NotNull final GameObject<?, ?, ?> item) {
74  super(container == null ? item + " was expected to be inside a container but wasn't." : item + " was expected to be inside " + container + " but was in " + item.getContainer());
75  this.container = container;
76  this.item = item;
77  }
78 
85  @NotNull
87  return item;
88  }
89 
95  @Nullable
97  return container;
98  }
99 
100 }
BaseObject<?, ?, ?, ?> getItem()
Returns the GameObject that was not inside a container but should have been.
Base class for classes that contain GameObjects as children in the sense of containment.
Base package of all Gridarta classes.
This exception is thrown in case a method of a GameObject without a container or the wrong container ...
NotInsideContainerException(@NotNull final GameObject<?, ?, ?> item)
Create a NotInsideContainerException.
final GameObjectContainer<?, ?, ?> container
The expected container if != null or null if expected to be in any container.
final BaseObject<?, ?, ?, ?> item
The GameObject that was not inside a / the container but should have been.
GameObjectContainer<?, ?, ?> getContainer()
Returns the Container that the GameObject was expected in.
NotInsideContainerException(@Nullable final GameObjectContainer<?, ?, ?> container, @NotNull final GameObject<?, ?, ?> item)
Create a NotInsideContainerException.