Package net.sf.gridarta.model.autojoin
Class AutojoinList<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.autojoin.AutojoinList<G,A,R>
-
- All Implemented Interfaces:
java.io.Serializable
public class AutojoinList<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements java.io.SerializableContains a list of (typically wall-)arches which do autojoining.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AutojoinList(@NotNull java.lang.Iterable<java.util.List<R>> archetypes)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetAlternativeIndex(R archetype)Returns the index of anArchetypeif it is an alternative archetype for any direction.RgetArchetype(int index)@NotNull java.lang.Iterable<R>getArchetypes(int index)Returns all archetypes for an index.intgetIndex(R archetype)Looks up the given node in the archetype array of this class.booleanisMainIndex(R archetype)Returns the index of anArchetypeif it is a main archetype for any direction.
-
-
-
Field Detail
-
SIZE
public static final int SIZE
The number of archetypes in an autojoin list.- See Also:
- Constant Field Values
-
NORTH
public static final int NORTH
- See Also:
- Constant Field Values
-
EAST
public static final int EAST
- See Also:
- Constant Field Values
-
SOUTH
public static final int SOUTH
- See Also:
- Constant Field Values
-
WEST
public static final int WEST
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AutojoinList
public AutojoinList(@NotNull @NotNull java.lang.Iterable<java.util.List<R>> archetypes) throws IllegalAutojoinListExceptionCreates a new instance.- Parameters:
archetypes- the archetypes that form a set of join-able archetypes- Throws:
IllegalAutojoinListException- if the autojoin list cannot be created
-
-
Method Detail
-
getIndex
public int getIndex(@NotNull R archetype)Looks up the given node in the archetype array of this class.- Parameters:
archetype- the node to lookup- Returns:
- the index of the node in the array
-
isMainIndex
public boolean isMainIndex(@NotNull R archetype)Returns the index of anArchetypeif it is a main archetype for any direction.- Parameters:
archetype- the archetype to check- Returns:
- whether the archetype is a main archetype
-
getAlternativeIndex
public int getAlternativeIndex(@NotNull R archetype)Returns the index of anArchetypeif it is an alternative archetype for any direction.- Parameters:
archetype- the archetype to check- Returns:
- the direction or
-1
-
getArchetype
@NotNull public R getArchetype(int index)
-
getArchetypes
@NotNull public @NotNull java.lang.Iterable<R> getArchetypes(int index)
Returns all archetypes for an index.- Parameters:
index- the index- Returns:
- the archetypes; the result contains at least one entry
-
-