Skip to content

Commit 6b1726a

Browse files
cleanup code and address revise
1 parent 3ad5f9f commit 6b1726a

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

module/dal/lib/src/main/java/org/openbase/bco/dal/lib/layer/service/provider/ColorStateProviderService.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
* #L%
2323
*/
2424

25+
import org.jetbrains.annotations.NotNull;
2526
import org.openbase.bco.dal.lib.layer.service.operation.OperationService;
2627
import org.openbase.jul.annotation.RPCMethod;
27-
import org.openbase.jul.exception.CouldNotPerformException;
2828
import org.openbase.jul.exception.CouldNotTransformException;
2929
import org.openbase.jul.exception.NotAvailableException;
3030
import org.openbase.jul.exception.VerificationFailedException;
@@ -38,6 +38,9 @@
3838
import org.openbase.type.vision.RGBColorType.RGBColor;
3939
import org.slf4j.LoggerFactory;
4040

41+
import java.util.function.DoubleUnaryOperator;
42+
import java.util.function.BiPredicate;
43+
4144
import static org.openbase.type.domotic.service.ServiceTemplateType.ServiceTemplate.ServiceType.COLOR_STATE_SERVICE;
4245

4346
/**
@@ -164,8 +167,7 @@ static Boolean isCompatible(final ColorState colorState, final PowerState powerS
164167
}
165168

166169
static Boolean equalServiceStates(final ColorState colorStateA, final ColorState colorStateB) {
167-
//TODO: explain this (required because of openhab) and put margins into constants
168-
170+
169171
final HSBColor hsbColorA = colorStateA.getColor().getHsbColor();
170172
final HSBColor hsbColorB = colorStateB.getColor().getHsbColor();
171173

@@ -176,13 +178,13 @@ static Boolean equalServiceStates(final ColorState colorStateA, final ColorState
176178
final double BRIGHTNESS_MARGIN = 0.01;
177179

178180
// normalize angle to [0,360)
179-
java.util.function.DoubleUnaryOperator normalize = (v) -> {
181+
DoubleUnaryOperator normalize = (v) -> {
180182
double r = v % 360.0;
181183
if (r < 0) r += 360.0;
182184
return r;
183185
};
184186

185-
java.util.function.BiPredicate<Double, Double> hueEqualsWithWrap = (ha, hb) -> {
187+
BiPredicate<Double, Double> hueEqualsWithWrap = (ha, hb) -> {
186188
double aNorm = normalize.applyAsDouble(ha);
187189
double bNorm = normalize.applyAsDouble(hb);
188190
double diff = Math.abs(aNorm - bNorm);

module/dal/lib/src/test/java/org/openbase/bco/dal/lib/layer/service/provider/ColorStateProviderServiceTest.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ import org.openbase.type.domotic.state.ColorStateType.ColorState
3535
class ColorStateProviderServiceTest {
3636
@Test
3737
@Timeout(10)
38-
@Throws(VerificationFailedException::class, JPServiceException::class)
39-
fun verifyColorState() {
38+
fun `should fix color values once they are defined out of range`() {
4039
JPService.setupJUnitTestMode()
4140

4241
val builder = ColorState.newBuilder()
@@ -70,7 +69,6 @@ class ColorStateProviderServiceTest {
7069

7170
@Test
7271
@Timeout(10)
73-
@Throws(VerificationFailedException::class, JPServiceException::class)
7472
fun `should handle color state comparison with equal state`() {
7573
JPService.setupJUnitTestMode()
7674

@@ -111,7 +109,6 @@ class ColorStateProviderServiceTest {
111109

112110
@Test
113111
@Timeout(10)
114-
@Throws(VerificationFailedException::class, JPServiceException::class)
115112
fun `should handle color state comparison with non equal state`() {
116113
JPService.setupJUnitTestMode()
117114

@@ -221,7 +218,6 @@ class ColorStateProviderServiceTest {
221218

222219
@Test
223220
@Timeout(10)
224-
@Throws(VerificationFailedException::class, JPServiceException::class)
225221
fun `should handle color state comparison with neutral state`() {
226222
JPService.setupJUnitTestMode()
227223

0 commit comments

Comments
 (0)