|
47 | 47 | import java.util.Collection; |
48 | 48 | import java.util.EnumSet; |
49 | 49 | import java.util.HashMap; |
50 | | -import java.util.HashSet; |
51 | 50 | import java.util.List; |
52 | 51 | import java.util.Locale; |
53 | 52 | import java.util.Map; |
@@ -650,7 +649,29 @@ private static Action.GradientPoint createGradientPoint(Pair<Double, Double> pai |
650 | 649 |
|
651 | 650 | private static boolean actionsDiffer(Scene scene, List<SceneAction> actions) { |
652 | 651 | List<SceneAction> currentActions = scene.getActions(); |
653 | | - return !new HashSet<>(currentActions).containsAll(actions); |
| 652 | + return !actions.stream().allMatch(action -> currentActions.stream().anyMatch( |
| 653 | + current -> sceneActionsMatch(current, action))); |
| 654 | + } |
| 655 | + |
| 656 | + private static boolean sceneActionsMatch(SceneAction a, SceneAction b) { |
| 657 | + if (!Objects.equals(a.getTarget(), b.getTarget())) { |
| 658 | + return false; |
| 659 | + } |
| 660 | + Action aa = a.getAction(); |
| 661 | + Action ba = b.getAction(); |
| 662 | + return Objects.equals(aa.getOn(), ba.getOn()) && |
| 663 | + dimmingMatches(aa.getDimming(), ba.getDimming()) && |
| 664 | + Objects.equals(aa.getColor(), ba.getColor()) && |
| 665 | + Objects.equals(aa.getColor_temperature(), ba.getColor_temperature()) && |
| 666 | + Objects.equals(aa.getEffects_v2(), ba.getEffects_v2()) && |
| 667 | + Objects.equals(aa.getGradient(), ba.getGradient()) && |
| 668 | + Objects.equals(aa.getDynamics(), ba.getDynamics()); |
| 669 | + } |
| 670 | + |
| 671 | + private static boolean dimmingMatches(Dimming a, Dimming b) { |
| 672 | + if (a == null && b == null) return true; |
| 673 | + if (a == null || b == null) return false; |
| 674 | + return Math.abs(a.getBrightness() - b.getBrightness()) < 0.5; |
654 | 675 | } |
655 | 676 |
|
656 | 677 | private String createScene(Scene newScene) { |
|
0 commit comments