| 1 | package org.sanmibuh.tedee.lock.domain.vo; | |
| 2 | ||
| 3 | import org.sanmibuh.tedee.lock.domain.exception.InvalidLockStateException; | |
| 4 | ||
| 5 | public enum LockState { | |
| 6 | UNCALIBRATED(0), | |
| 7 | CALIBRATION(1), | |
| 8 | OPEN(2), | |
| 9 | PARTIALLY_OPEN(3), | |
| 10 | OPENING(4), | |
| 11 | CLOSING(5), | |
| 12 | CLOSED(6), | |
| 13 | PULL_SPRING(7), | |
| 14 | PULLING(8), | |
| 15 | UNKNOWN(9), | |
| 16 | UNPULLING(255); | |
| 17 | ||
| 18 | private final int bridgeCode; | |
| 19 | ||
| 20 | LockState(final int bridgeCode) { | |
| 21 | this.bridgeCode = bridgeCode; | |
| 22 | } | |
| 23 | ||
| 24 | public static LockState fromBridgeCode(final int bridgeCode) { | |
| 25 | for (final var state : values()) { | |
| 26 |
1
1. fromBridgeCode : negated conditional → KILLED |
if (state.bridgeCode == bridgeCode) { |
| 27 |
1
1. fromBridgeCode : replaced return value with null for org/sanmibuh/tedee/lock/domain/vo/LockState::fromBridgeCode → KILLED |
return state; |
| 28 | } | |
| 29 | } | |
| 30 | throw new InvalidLockStateException(bridgeCode); | |
| 31 | } | |
| 32 | } | |
Mutations | ||
| 26 |
1.1 |
|
| 27 |
1.1 |