Module org.refcodes.checkerboard
Package org.refcodes.checkerboard
Class AbstractCheckerboard<T extends Checkerboard<P,S>,P extends Player<P,S>,S>
java.lang.Object
org.refcodes.observer.AbstractObservable<CheckerboardObserver<P,S>,org.refcodes.observer.GenericEvent<?>>
org.refcodes.checkerboard.AbstractCheckerboard<T,P,S>
- Type Parameters:
P
- the generic typeS
- the generic type
- All Implemented Interfaces:
Checkerboard<P,
,S> Players<P>
,org.refcodes.component.Component
,org.refcodes.component.Destroyable
,org.refcodes.graphical.GridDimension
,org.refcodes.graphical.GridDimension.GridDimensionAccessor
,org.refcodes.graphical.GridDimension.GridDimensionBuilder<Checkerboard<P,
,S>> org.refcodes.graphical.GridDimension.GridDimensionMutator
,org.refcodes.graphical.GridDimension.GridDimensionProperty
,org.refcodes.graphical.GridHeightAccessor
,org.refcodes.graphical.GridHeightAccessor.GridHeightBuilder<Checkerboard<P,
,S>> org.refcodes.graphical.GridHeightAccessor.GridHeightMutator
,org.refcodes.graphical.GridHeightAccessor.GridHeightProperty
,org.refcodes.graphical.GridModeAccessor
,org.refcodes.graphical.GridModeAccessor.GridModeBuilder<Checkerboard<P,
,S>> org.refcodes.graphical.GridModeAccessor.GridModeMutator
,org.refcodes.graphical.GridModeAccessor.GridModeProperty
,org.refcodes.graphical.GridWidthAccessor
,org.refcodes.graphical.GridWidthAccessor.GridWidthBuilder<Checkerboard<P,
,S>> org.refcodes.graphical.GridWidthAccessor.GridWidthMutator
,org.refcodes.graphical.GridWidthAccessor.GridWidthProperty
,org.refcodes.mixin.Disposable
,org.refcodes.mixin.Loggable
,org.refcodes.observer.Observable<CheckerboardObserver<P,
S>>
public abstract class AbstractCheckerboard<T extends Checkerboard<P,S>,P extends Player<P,S>,S>
extends org.refcodes.observer.AbstractObservable<CheckerboardObserver<P,S>,org.refcodes.observer.GenericEvent<?>>
implements Checkerboard<P,S>
The Class CheckerboardImpl.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable
org.refcodes.component.Destroyable.DestroyAutomaton
Nested classes/interfaces inherited from interface org.refcodes.graphical.GridDimension
org.refcodes.graphical.GridDimension.GridDimensionAccessor, org.refcodes.graphical.GridDimension.GridDimensionBuilder<B extends org.refcodes.graphical.GridDimension.GridDimensionBuilder<B>>, org.refcodes.graphical.GridDimension.GridDimensionMutator, org.refcodes.graphical.GridDimension.GridDimensionProperty
Nested classes/interfaces inherited from interface org.refcodes.graphical.GridHeightAccessor
org.refcodes.graphical.GridHeightAccessor.GridHeightBuilder<B extends org.refcodes.graphical.GridHeightAccessor.GridHeightBuilder<B>>, org.refcodes.graphical.GridHeightAccessor.GridHeightMutator, org.refcodes.graphical.GridHeightAccessor.GridHeightProperty
Nested classes/interfaces inherited from interface org.refcodes.graphical.GridModeAccessor
org.refcodes.graphical.GridModeAccessor.GridModeBuilder<B extends org.refcodes.graphical.GridModeAccessor.GridModeBuilder<B>>, org.refcodes.graphical.GridModeAccessor.GridModeMutator, org.refcodes.graphical.GridModeAccessor.GridModeProperty
Nested classes/interfaces inherited from interface org.refcodes.graphical.GridWidthAccessor
org.refcodes.graphical.GridWidthAccessor.GridWidthBuilder<B extends org.refcodes.graphical.GridWidthAccessor.GridWidthBuilder<B>>, org.refcodes.graphical.GridWidthAccessor.GridWidthMutator, org.refcodes.graphical.GridWidthAccessor.GridWidthProperty
-
Field Summary
Fields inherited from interface org.refcodes.mixin.Loggable
RUNTIME_LOGGER_CLASS, RUNTIME_LOGGER_FACTORY_CLASS, RUNTIME_LOGGER_FACTORY_METHOD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionatBottomLeftOf
(org.refcodes.graphical.Position aPos) At bottom left of.atBottomOf
(org.refcodes.graphical.Position aPos) At bottom of.atBottomRightOf
(org.refcodes.graphical.Position aPos) At bottom right of.atLeftOf
(org.refcodes.graphical.Position aPos) At left of.atPosition
(int aPosX, int aPosY) At position.atPosition
(org.refcodes.graphical.Position aPos) At position.atRightOf
(org.refcodes.graphical.Position aPos) At right of.atTopLeftOf
(org.refcodes.graphical.Position aPos) At top left of.atTopOf
(org.refcodes.graphical.Position aPos) At top of.atTopRightOf
(org.refcodes.graphical.Position aPos) At top right of.void
Clear players.void
destroy()
boolean
protected boolean
fireEvent
(org.refcodes.observer.GenericEvent<?> aEvent, CheckerboardObserver<P, S> aObserver, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) Fire event.void
Performs the given action for eachPlayer
on theCheckerboard
until all players have been processed or the action throws an exception.getColumn
(int aColumn) Gets the column.int
org.refcodes.graphical.GridMode
int
Gets the players.getRow
(int aRow) Gets the row.boolean
hasAtBottomLeftOf
(org.refcodes.graphical.Position aPos) Checks for at bottom left of.boolean
hasAtBottomOf
(org.refcodes.graphical.Position aPos) Checks for at bottom of.boolean
hasAtBottomRightOf
(org.refcodes.graphical.Position aPos) Checks for at bottom right of.boolean
hasAtLeftOf
(org.refcodes.graphical.Position aPos) Checks for at left of.boolean
hasAtPosition
(int aPosX, int aPosY) Checks for at position.boolean
hasAtPosition
(org.refcodes.graphical.Position aPos) Checks for at position.boolean
hasAtRightOf
(org.refcodes.graphical.Position aPos) Checks for at right of.boolean
hasAtTopLeftOf
(org.refcodes.graphical.Position aPos) Checks for at top left of.boolean
hasAtTopOf
(org.refcodes.graphical.Position aPos) Checks for at top of.boolean
hasAtTopRightOf
(org.refcodes.graphical.Position aPos) Checks for at top right of.int
hashCode()
boolean
Checks for player.boolean
Checks for players.int
Player count.players()
Players.Put player.boolean
removePlayer
(P aPlayer) Removes the player.void
setGridDimension
(int aWidth, int aHeight) void
setGridDimension
(org.refcodes.graphical.Dimension aDimension) void
setGridDimension
(org.refcodes.graphical.GridDimension aDimension) void
setGridHeight
(int aHeight) void
setGridMode
(org.refcodes.graphical.GridMode aGridMode) void
setGridWidth
(int aWidth) boolean
subscribeObserver
(CheckerboardObserver<P, S> aObserver) boolean
unsubscribeObserver
(CheckerboardObserver<P, S> aObserver) withGridDimension
(int aGridWidth, int aGridHeight) withGridDimension
(org.refcodes.graphical.Dimension aDimension) withGridDimension
(org.refcodes.graphical.GridDimension aDimension) withGridHeight
(int aHeight) withGridMode
(org.refcodes.graphical.GridMode aGridMode) withGridWidth
(int aWidth) Methods inherited from class org.refcodes.observer.AbstractObservable
clear, dispose, doHandleEventListenerException, fireEvent, getThreadPriority, hasObserverSubscription, isEmpty, isObserversActive, observers, setObserversActive, setThreadPriority, size
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.graphical.GridDimension
isInBounds, isInBounds, isInHeight, isInWidth
Methods inherited from interface org.refcodes.graphical.GridDimension.GridDimensionProperty
letGridDimension, letGridDimension, letGridDimension
Methods inherited from interface org.refcodes.graphical.GridHeightAccessor.GridHeightProperty
letGridHeight
Methods inherited from interface org.refcodes.graphical.GridModeAccessor.GridModeProperty
letGridMode
Methods inherited from interface org.refcodes.graphical.GridWidthAccessor.GridWidthProperty
letGridWidth
Methods inherited from interface org.refcodes.mixin.Loggable
alert, alert, critical, critical, debug, error, info, notice, panic, trace, warn, warn
Methods inherited from interface org.refcodes.observer.Observable
hasObserverSubscription
Methods inherited from interface org.refcodes.checkerboard.Players
firstPlayer, players
-
Constructor Details
-
AbstractCheckerboard
public AbstractCheckerboard()
-
-
Method Details
-
withGridMode
- Specified by:
withGridMode
in interfaceorg.refcodes.graphical.GridModeAccessor.GridModeBuilder<T extends Checkerboard<P,
S>>
-
withGridDimension
- Specified by:
withGridDimension
in interfaceorg.refcodes.graphical.GridDimension.GridDimensionBuilder<T extends Checkerboard<P,
S>>
-
withGridDimension
- Specified by:
withGridDimension
in interfaceorg.refcodes.graphical.GridDimension.GridDimensionBuilder<T extends Checkerboard<P,
S>>
-
withGridDimension
- Specified by:
withGridDimension
in interfaceorg.refcodes.graphical.GridDimension.GridDimensionBuilder<T extends Checkerboard<P,
S>>
-
withGridWidth
- Specified by:
withGridWidth
in interfaceorg.refcodes.graphical.GridWidthAccessor.GridWidthBuilder<T extends Checkerboard<P,
S>>
-
withGridHeight
- Specified by:
withGridHeight
in interfaceorg.refcodes.graphical.GridHeightAccessor.GridHeightBuilder<T extends Checkerboard<P,
S>>
-
forEach
Performs the given action for eachPlayer
on theCheckerboard
until all players have been processed or the action throws an exception. -
hasAtPosition
Checks for at position.- Specified by:
hasAtPosition
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtPosition
Checks for at position.- Specified by:
hasAtPosition
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPosX
- the pos XaPosY
- the pos Y- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atPosition
At position.- Specified by:
atPosition
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atPosition
At position.- Specified by:
atPosition
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPosX
- the pos XaPosY
- the pos Y- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtTopOf
Checks for at top of.- Specified by:
hasAtTopOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atTopOf
At top of.- Specified by:
atTopOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtTopRightOf
public boolean hasAtTopRightOf(org.refcodes.graphical.Position aPos) throws IndexOutOfBoundsException Checks for at top right of.- Specified by:
hasAtTopRightOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atTopRightOf
At top right of.- Specified by:
atTopRightOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtRightOf
Checks for at right of.- Specified by:
hasAtRightOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atRightOf
At right of.- Specified by:
atRightOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtBottomRightOf
public boolean hasAtBottomRightOf(org.refcodes.graphical.Position aPos) throws IndexOutOfBoundsException Checks for at bottom right of.- Specified by:
hasAtBottomRightOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atBottomRightOf
At bottom right of.- Specified by:
atBottomRightOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtBottomOf
Checks for at bottom of.- Specified by:
hasAtBottomOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atBottomOf
At bottom of.- Specified by:
atBottomOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtBottomLeftOf
public boolean hasAtBottomLeftOf(org.refcodes.graphical.Position aPos) throws IndexOutOfBoundsException Checks for at bottom left of.- Specified by:
hasAtBottomLeftOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atBottomLeftOf
At bottom left of.- Specified by:
atBottomLeftOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtLeftOf
Checks for at left of.- Specified by:
hasAtLeftOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atLeftOf
At left of.- Specified by:
atLeftOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
hasAtTopLeftOf
public boolean hasAtTopLeftOf(org.refcodes.graphical.Position aPos) throws IndexOutOfBoundsException Checks for at top left of.- Specified by:
hasAtTopLeftOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- true, if successful
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
atTopLeftOf
At top left of.- Specified by:
atTopLeftOf
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aPos
- the pos- Returns:
- the p
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
getRow
Gets the row.- Specified by:
getRow
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aRow
- the row- Returns:
- the row
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
getColumn
Gets the column.- Specified by:
getColumn
in interfaceCheckerboard<T extends Checkerboard<P,
S>, P extends Player<P, S>> - Parameters:
aColumn
- the column- Returns:
- the column
- Throws:
IndexOutOfBoundsException
- the index out of bounds exception
-
getGridMode
public org.refcodes.graphical.GridMode getGridMode()- Specified by:
getGridMode
in interfaceorg.refcodes.graphical.GridModeAccessor
-
setGridMode
public void setGridMode(org.refcodes.graphical.GridMode aGridMode) - Specified by:
setGridMode
in interfaceorg.refcodes.graphical.GridModeAccessor.GridModeMutator
-
getPlayers
Gets the players.- Specified by:
getPlayers
in interfacePlayers<T extends Checkerboard<P,
S>> - Returns:
- the players
-
putPlayer
Put player. -
removePlayer
Removes the player.- Specified by:
removePlayer
in interfacePlayers<T extends Checkerboard<P,
S>> - Parameters:
aPlayer
- the element- Returns:
- true, if successful
-
clearPlayers
public void clearPlayers()Clear players.- Specified by:
clearPlayers
in interfacePlayers<T extends Checkerboard<P,
S>>
-
playerCount
public int playerCount()Player count.- Specified by:
playerCount
in interfacePlayers<T extends Checkerboard<P,
S>> - Returns:
- the int
-
hasPlayers
public boolean hasPlayers()Checks for players.- Specified by:
hasPlayers
in interfacePlayers<T extends Checkerboard<P,
S>> - Returns:
- true, if successful
-
players
Players. -
hasPlayer
Checks for player. -
getGridWidth
public int getGridWidth()- Specified by:
getGridWidth
in interfaceorg.refcodes.graphical.GridWidthAccessor
-
setGridDimension
public void setGridDimension(int aWidth, int aHeight) - Specified by:
setGridDimension
in interfaceorg.refcodes.graphical.GridDimension.GridDimensionMutator
-
setGridDimension
public void setGridDimension(org.refcodes.graphical.GridDimension aDimension) - Specified by:
setGridDimension
in interfaceorg.refcodes.graphical.GridDimension.GridDimensionMutator
-
setGridDimension
public void setGridDimension(org.refcodes.graphical.Dimension aDimension) - Specified by:
setGridDimension
in interfaceorg.refcodes.graphical.GridDimension.GridDimensionMutator
-
setGridWidth
public void setGridWidth(int aWidth) - Specified by:
setGridWidth
in interfaceorg.refcodes.graphical.GridWidthAccessor.GridWidthMutator
-
setGridHeight
public void setGridHeight(int aHeight) - Specified by:
setGridHeight
in interfaceorg.refcodes.graphical.GridHeightAccessor.GridHeightMutator
-
getGridHeight
public int getGridHeight()- Specified by:
getGridHeight
in interfaceorg.refcodes.graphical.GridHeightAccessor
-
subscribeObserver
- Specified by:
subscribeObserver
in interfaceorg.refcodes.observer.Observable<T extends Checkerboard<P,
S>> - Overrides:
subscribeObserver
in classorg.refcodes.observer.AbstractObservable<CheckerboardObserver<P extends Player<P,
S>, S>, org.refcodes.observer.GenericEvent<?>>
-
unsubscribeObserver
- Specified by:
unsubscribeObserver
in interfaceorg.refcodes.observer.Observable<T extends Checkerboard<P,
S>> - Overrides:
unsubscribeObserver
in classorg.refcodes.observer.AbstractObservable<CheckerboardObserver<P extends Player<P,
S>, S>, org.refcodes.observer.GenericEvent<?>>
-
destroy
public void destroy()- Specified by:
destroy
in interfaceorg.refcodes.component.Destroyable
-
hashCode
public int hashCode() -
equals
-
fireEvent
protected boolean fireEvent(org.refcodes.observer.GenericEvent<?> aEvent, CheckerboardObserver<P, S> aObserver, org.refcodes.controlflow.ExecutionStrategy aExecutionStrategy) throws org.refcodes.exception.VetoExceptionFire event.- Specified by:
fireEvent
in classorg.refcodes.observer.AbstractObservable<CheckerboardObserver<P extends Player<P,
S>, S>, org.refcodes.observer.GenericEvent<?>> - Parameters:
aEvent
- the eventaObserver
- the observeraExecutionStrategy
- the execution strategy- Returns:
- true, if successful
- Throws:
org.refcodes.exception.VetoException
- the veto exception
-