From baa580c6f4c89efa0213b75faf7aec1ff0b9e690 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Fri, 22 Jan 2016 11:12:30 +0000
Subject: [PATCH] Replace for with foreach.

I don't care but Android Studio complains.
---
 .../src/org/briarproject/db/JdbcDatabase.java | 75 ++++++++-----------
 1 file changed, 33 insertions(+), 42 deletions(-)

diff --git a/briar-core/src/org/briarproject/db/JdbcDatabase.java b/briar-core/src/org/briarproject/db/JdbcDatabase.java
index 7ac90a5a90..05b9d2ce24 100644
--- a/briar-core/src/org/briarproject/db/JdbcDatabase.java
+++ b/briar-core/src/org/briarproject/db/JdbcDatabase.java
@@ -514,9 +514,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 				int[] batchAffected = ps.executeBatch();
 				if (batchAffected.length != ids.size())
 					throw new DbStateException();
-				for (int i = 0; i < batchAffected.length; i++) {
-					if (batchAffected[i] != 1) throw new DbStateException();
-				}
+				for (int rows : batchAffected)
+					if (rows != 1) throw new DbStateException();
 				ps.close();
 			}
 			// Make groups that are visible to everyone visible to this contact
@@ -539,9 +538,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 				int[] batchAffected = ps.executeBatch();
 				if (batchAffected.length != ids.size())
 					throw new DbStateException();
-				for (int i = 0; i < batchAffected.length; i++) {
-					if (batchAffected[i] != 1) throw new DbStateException();
-				}
+				for (int rows : batchAffected)
+					if (rows != 1) throw new DbStateException();
 				ps.close();
 			}
 			// Create a group version row
@@ -796,9 +794,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 			ps.addBatch();
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != 3) throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] != 1) throw new DbStateException();
-			}
+			for (int rows : batchAffected)
+				if (rows != 1) throw new DbStateException();
 			ps.close();
 			// Store the outgoing keys
 			sql = "INSERT INTO outgoingKeys (contactId, transportId, period,"
@@ -1921,9 +1918,9 @@ abstract class JdbcDatabase implements Database<Connection> {
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != acked.size())
 				throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] < 0) throw new DbStateException();
-				if (batchAffected[i] > 1) throw new DbStateException();
+			for (int rows : batchAffected) {
+				if (rows < 0) throw new DbStateException();
+				if (rows > 1) throw new DbStateException();
 			}
 			ps.close();
 		} catch (SQLException e) {
@@ -1947,9 +1944,9 @@ abstract class JdbcDatabase implements Database<Connection> {
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != requested.size())
 				throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] < 0) throw new DbStateException();
-				if (batchAffected[i] > 1) throw new DbStateException();
+			for (int rows: batchAffected) {
+				if (rows < 0) throw new DbStateException();
+				if (rows > 1) throw new DbStateException();
 			}
 			ps.close();
 		} catch (SQLException e) {
@@ -1992,9 +1989,9 @@ abstract class JdbcDatabase implements Database<Connection> {
 				int[] batchAffected = ps.executeBatch();
 				if (batchAffected.length != removed.size())
 					throw new DbStateException();
-				for (int i = 0; i < batchAffected.length; i++) {
-					if (batchAffected[i] < 0) throw new DbStateException();
-					if (batchAffected[i] > 1) throw new DbStateException();
+				for (int rows : batchAffected) {
+					if (rows < 0) throw new DbStateException();
+					if (rows > 1) throw new DbStateException();
 				}
 				ps.close();
 			}
@@ -2012,9 +2009,9 @@ abstract class JdbcDatabase implements Database<Connection> {
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != retained.size())
 				throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] < 0) throw new DbStateException();
-				if (batchAffected[i] > 1) throw new DbStateException();
+			for (int rows : batchAffected) {
+				if (rows < 0) throw new DbStateException();
+				if (rows > 1) throw new DbStateException();
 			}
 			// Insert any keys that don't already exist
 			sql = "INSERT INTO " + tableName
@@ -2034,9 +2031,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 			}
 			batchAffected = ps.executeBatch();
 			if (batchAffected.length != inserted) throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] != 1) throw new DbStateException();
-			}
+			for (int rows : batchAffected)
+				if (rows != 1) throw new DbStateException();
 			ps.close();
 		} catch (SQLException e) {
 			tryToClose(ps);
@@ -2060,9 +2056,9 @@ abstract class JdbcDatabase implements Database<Connection> {
 			}
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != s.size()) throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] < 0) throw new DbStateException();
-				if (batchAffected[i] > 1) throw new DbStateException();
+			for (int rows : batchAffected) {
+				if (rows < 0) throw new DbStateException();
+				if (rows > 1) throw new DbStateException();
 			}
 			// Insert any settings that don't already exist
 			sql = "INSERT INTO settings (key, value, namespace)"
@@ -2081,9 +2077,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 			}
 			batchAffected = ps.executeBatch();
 			if (batchAffected.length != inserted) throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] != 1) throw new DbStateException();
-			}
+			for (int rows : batchAffected)
+				if (rows != 1) throw new DbStateException();
 			ps.close();
 		} catch (SQLException e) {
 			tryToClose(ps);
@@ -2195,9 +2190,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != visible.size())
 				throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] != 1) throw new DbStateException();
-			}
+			for (int rows : batchAffected)
+				if (rows != 1) throw new DbStateException();
 			ps.close();
 		} catch (SQLException e) {
 			tryToClose(ps);
@@ -2271,9 +2265,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != requested.size())
 				throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] != 1) throw new DbStateException();
-			}
+			for (int rows : batchAffected)
+				if (rows != 1) throw new DbStateException();
 			ps.close();
 		} catch (SQLException e) {
 			tryToClose(ps);
@@ -2465,9 +2458,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 				int[] batchAffected = ps.executeBatch();
 				if (batchAffected.length != removed.size())
 					throw new DbStateException();
-				for (int i = 0; i < batchAffected.length; i++) {
-					if (batchAffected[i] < 0) throw new DbStateException();
-				}
+				for (int rows : batchAffected)
+					if (rows < 0) throw new DbStateException();
 				ps.close();
 			}
 			// Delete the existing subscriptions, if any
@@ -2491,9 +2483,8 @@ abstract class JdbcDatabase implements Database<Connection> {
 			int[] batchAffected = ps.executeBatch();
 			if (batchAffected.length != groups.size())
 				throw new DbStateException();
-			for (int i = 0; i < batchAffected.length; i++) {
-				if (batchAffected[i] != 1) throw new DbStateException();
-			}
+			for (int rows : batchAffected)
+				if (rows != 1) throw new DbStateException();
 			ps.close();
 			return true;
 		} catch (SQLException e) {
-- 
GitLab