-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added backend system for red and green signals in UI
- Loading branch information
Showing
7 changed files
with
213 additions
and
11 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/com/troblecodings/signals/core/ModeIdentifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.troblecodings.signals.core; | ||
|
||
import java.util.Objects; | ||
|
||
import com.troblecodings.core.ReadBuffer; | ||
import com.troblecodings.core.WriteBuffer; | ||
import com.troblecodings.signals.signalbox.ModeSet; | ||
import com.troblecodings.signals.signalbox.Point; | ||
|
||
public class ModeIdentifier { | ||
|
||
public final Point point; | ||
public final ModeSet mode; | ||
|
||
public ModeIdentifier(final Point point, final ModeSet mode) { | ||
this.point = point; | ||
this.mode = mode; | ||
} | ||
|
||
public void writeNetwork(final WriteBuffer buffer) { | ||
point.writeNetwork(buffer); | ||
mode.writeNetwork(buffer); | ||
} | ||
|
||
public static ModeIdentifier of(final ReadBuffer buffer) { | ||
return new ModeIdentifier(Point.of(buffer), ModeSet.of(buffer)); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(mode, point); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
final ModeIdentifier other = (ModeIdentifier) obj; | ||
return Objects.equals(mode, other.mode) && Objects.equals(point, other.point); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ModeIdentifier [point=" + point + ",mode=" + mode + "]"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.