Class DefaultArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.archetypeset.DefaultArchetypeSet<G,A,R>
-
- All Implemented Interfaces:
ArchetypeSet<G,A,R>
public class DefaultArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements ArchetypeSet<G,A,R>
Base implementation of ArchetypeSet.
-
-
Constructor Summary
Constructors Constructor Description DefaultArchetypeSet(@NotNull ArchetypeFactory<G,A,R> archetypeFactory, @Nullable java.lang.String imageSet)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddArchetype(R archetype)Adds an Archetype to this Set.voidaddArchetypeSetListener(@NotNull ArchetypeSetListener<G,A,R> listener)Registers an ArchetypeSetListener.voidconnectFaces()RgetArchetype(@NotNull java.lang.String archetypeName)Returns an Archetype by its name.intgetArchetypeCount()Returns the number of Archetypes available.@NotNull java.util.Collection<R>getArchetypes()Returns a read-only collection of allArchetypes.@Nullable java.lang.StringgetImageSet()Returns the image set.RgetOrCreateArchetype(@NotNull java.lang.String archetypeName)Returns an archetype by its name.booleanisLoadedFromArchive()Returns whether the Archetypes in this ArchetypeSet were loaded from an archive.voidremoveArchetypeSetListener(@NotNull ArchetypeSetListener<G,A,R> listener)Removes anArchetypeSetListener.voidsetLoadedFromArchive(boolean loadedFromArchive)Sets whether Archetypes were loaded from an archive.
-
-
-
Constructor Detail
-
DefaultArchetypeSet
public DefaultArchetypeSet(@NotNull @NotNull ArchetypeFactory<G,A,R> archetypeFactory, @Nullable @Nullable java.lang.String imageSet)Creates a new instance.- Parameters:
archetypeFactory- the archetype factory to useimageSet- the image set to use
-
-
Method Detail
-
getImageSet
@Nullable public @Nullable java.lang.String getImageSet()
Description copied from interface:ArchetypeSetReturns the image set.- Specified by:
getImageSetin interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the image set or
null
-
isLoadedFromArchive
public boolean isLoadedFromArchive()
Description copied from interface:ArchetypeSetReturns whether the Archetypes in this ArchetypeSet were loaded from an archive.- Specified by:
isLoadedFromArchivein interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
trueif loaded from an archive, otherwisefalse
-
getArchetypeCount
public int getArchetypeCount()
Description copied from interface:ArchetypeSetReturns the number of Archetypes available.- Specified by:
getArchetypeCountin interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the number of Archetypes available
-
getArchetype
@NotNull public R getArchetype(@NotNull @NotNull java.lang.String archetypeName) throws UndefinedArchetypeException
Description copied from interface:ArchetypeSetReturns an Archetype by its name.- Specified by:
getArchetypein interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
archetypeName- the name of the Archetype to get- Returns:
- the archetype
- Throws:
UndefinedArchetypeException- if the no such archetype exists- See Also:
for a similar method that creates undefined archetypes
-
getOrCreateArchetype
@NotNull public R getOrCreateArchetype(@NotNull @NotNull java.lang.String archetypeName)
Description copied from interface:ArchetypeSetReturns an archetype by its name. If this archetype does not exist, return anArchetypewhich hasArchetype.isUndefinedArchetype()set.- Specified by:
getOrCreateArchetypein interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
archetypeName- the archetype name- Returns:
- the archetype
- See Also:
ArchetypeSet.getArchetype(String)
-
addArchetype
public void addArchetype(@NotNull R archetype) throws DuplicateArchetypeExceptionDescription copied from interface:ArchetypeSetAdds an Archetype to this Set.- Specified by:
addArchetypein interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
archetype- the archetype to add- Throws:
DuplicateArchetypeException- if the archetype name is not unique
-
setLoadedFromArchive
public void setLoadedFromArchive(boolean loadedFromArchive)
Description copied from interface:ArchetypeSetSets whether Archetypes were loaded from an archive.- Specified by:
setLoadedFromArchivein interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
loadedFromArchive-truewhen loaded from archive, otherwisefalse- See Also:
ArchetypeSet.isLoadedFromArchive()
-
getArchetypes
@NotNull public @NotNull java.util.Collection<R> getArchetypes()
Description copied from interface:ArchetypeSetReturns a read-only collection of allArchetypes.- Specified by:
getArchetypesin interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- a read-only collection of all archetypes
-
addArchetypeSetListener
public void addArchetypeSetListener(@NotNull @NotNull ArchetypeSetListener<G,A,R> listener)Registers an ArchetypeSetListener.- Specified by:
addArchetypeSetListenerin interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
listener- ArchetypeSetListener to register
-
removeArchetypeSetListener
public void removeArchetypeSetListener(@NotNull @NotNull ArchetypeSetListener<G,A,R> listener)Description copied from interface:ArchetypeSetRemoves anArchetypeSetListener.- Specified by:
removeArchetypeSetListenerin interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
listener- the listener to remove
-
connectFaces
public void connectFaces()
- Specified by:
connectFacesin interfaceArchetypeSet<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
-