[miio] cleanup several SAT warnings (#10871)

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
Marcel
2021-06-16 10:28:44 +02:00
committed by GitHub
parent 28c513ac3a
commit 36d7dc26b8
4 changed files with 9 additions and 19 deletions

View File

@@ -88,7 +88,7 @@ public class MiIoHandlerFactory extends BaseThingHandlerFactory {
} }
@Deactivate @Deactivate
private void dispose() { public void dispose() {
final Future<Boolean> scheduledTask = this.scheduledTask; final Future<Boolean> scheduledTask = this.scheduledTask;
if (scheduledTask != null && !scheduledTask.isDone()) { if (scheduledTask != null && !scheduledTask.isDone()) {
scheduledTask.cancel(true); scheduledTask.cancel(true);

View File

@@ -121,11 +121,7 @@ public class MiIoBasicChannel {
} }
public boolean isMiOt() { public boolean isMiOt() {
if (piid != null && siid != null && (getPiid() != 0 || getSiid() != 0)) { return (piid != null && siid != null && (getPiid() != 0 || getSiid() != 0));
return true;
} else {
return false;
}
} }
public String getFriendlyName() { public String getFriendlyName() {

View File

@@ -29,15 +29,13 @@ import org.openhab.core.library.unit.Units;
public class MiIoQuantityTypesTest { public class MiIoQuantityTypesTest {
@Test @Test
public void UnknownUnitTest() { public void unknownUnitTest() {
String unitName = "some none existent unit"; String unitName = "some none existent unit";
assertNull(MiIoQuantiyTypes.get(unitName)); assertNull(MiIoQuantiyTypes.get(unitName));
} }
@Test @Test
public void regularsUnitTest() { public void regularsUnitTest() {
String unitName = "minute"; String unitName = "minute";
assertEquals(Units.MINUTE, MiIoQuantiyTypes.get(unitName)); assertEquals(Units.MINUTE, MiIoQuantiyTypes.get(unitName));
@@ -47,7 +45,6 @@ public class MiIoQuantityTypesTest {
@Test @Test
public void aliasUnitsTest() { public void aliasUnitsTest() {
String unitName = "square_meter"; String unitName = "square_meter";
assertEquals(SIUnits.SQUARE_METRE, MiIoQuantiyTypes.get(unitName)); assertEquals(SIUnits.SQUARE_METRE, MiIoQuantiyTypes.get(unitName));

View File

@@ -149,7 +149,7 @@ public class RoboMapViewer extends JFrame {
@Override @Override
public void mouseMoved(@Nullable MouseEvent e) { public void mouseMoved(@Nullable MouseEvent e) {
if (e != null) { if (e != null) {
MapPoint roboMouseLocation = MapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint())); MapPoint roboMouseLocation = mapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint()));
updateStatusLine(roboMouseLocation); updateStatusLine(roboMouseLocation);
} }
} }
@@ -164,7 +164,7 @@ public class RoboMapViewer extends JFrame {
repaint(); repaint();
if (rrDrawPanel.hasDrawZone()) { if (rrDrawPanel.hasDrawZone()) {
final MapPoint endLocation = MapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint())); final MapPoint endLocation = mapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint()));
double minX = Math.min(fromLocation.getX(), endLocation.getX()); double minX = Math.min(fromLocation.getX(), endLocation.getX());
double maxX = Math.max(fromLocation.getX(), endLocation.getX()); double maxX = Math.max(fromLocation.getX(), endLocation.getX());
double minY = Math.min(fromLocation.getY(), endLocation.getY()); double minY = Math.min(fromLocation.getY(), endLocation.getY());
@@ -173,7 +173,7 @@ public class RoboMapViewer extends JFrame {
"Zone coordinates:\t%s, %s\t\tZone clean command: app_zoned_clean[[ %.0f,%.0f,%.0f,%.0f,1 ]]\r\n", "Zone coordinates:\t%s, %s\t\tZone clean command: app_zoned_clean[[ %.0f,%.0f,%.0f,%.0f,1 ]]\r\n",
endLocation, fromLocation, minX, minY, maxX, maxY)); endLocation, fromLocation, minX, minY, maxX, maxY));
} else { } else {
final MapPoint pointLocation = MapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint())); final MapPoint pointLocation = mapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint()));
textArea.append(String.format( textArea.append(String.format(
"GoTo coordinates:\t[X=%.0f, Y=%.0f]\t\tGoto command: app_goto_target[ %.0f,%.0f ]\r\n", "GoTo coordinates:\t[X=%.0f, Y=%.0f]\t\tGoto command: app_goto_target[ %.0f,%.0f ]\r\n",
pointLocation.getX(), pointLocation.getY(), pointLocation.getX(), pointLocation.getX(), pointLocation.getY(), pointLocation.getX(),
@@ -186,7 +186,7 @@ public class RoboMapViewer extends JFrame {
public void mousePressed(@Nullable MouseEvent e) { public void mousePressed(@Nullable MouseEvent e) {
if (e != null) { if (e != null) {
rrDrawPanel.setStartPoint(e.getX(), e.getY()); rrDrawPanel.setStartPoint(e.getX(), e.getY());
fromLocation = MapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint())); fromLocation = mapCoordstoRoboCoords(localCoordtoMapCoords(e.getPoint()));
} }
} }
@@ -296,7 +296,7 @@ public class RoboMapViewer extends JFrame {
} }
} }
private MapPoint MapCoordstoRoboCoords(MapPoint imagePoint) { private MapPoint mapCoordstoRoboCoords(MapPoint imagePoint) {
final RRMapDraw rrMap = this.rrMap; final RRMapDraw rrMap = this.rrMap;
if (rrMap != null) { if (rrMap != null) {
final RRMapFileParser mapDetails = rrMap.getMapParseDetails(); final RRMapFileParser mapDetails = rrMap.getMapParseDetails();
@@ -484,10 +484,7 @@ class RRDrawPanel extends JPanel {
public boolean hasDrawZone() { public boolean hasDrawZone() {
int pw = Math.abs(x - x2); int pw = Math.abs(x - x2);
int ph = Math.abs(y - y2); int ph = Math.abs(y - y2);
if (pw != 0 && ph != 0) { return pw != 0 && ph != 0;
return true;
}
return false;
} }
public void drawZoneRect(Graphics g, int x, int y, int x2, int y2) { public void drawZoneRect(Graphics g, int x, int y, int x2, int y2) {