]> git.mxchange.org Git - jcustomer-core.git/commitdiff
keep some variables inside loop scope
authorRoland Haeder <roland@mxchange.org>
Fri, 2 Oct 2015 07:38:26 +0000 (09:38 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 2 Oct 2015 07:38:26 +0000 (09:38 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jshopcore/model/customer/CustomerUtils.java

index 5eb699c9c32aa74aa56e76504d195b1e5e919f98..e3e5cd71fb78e2915b73625761d87a3cd9726bf8 100644 (file)
@@ -58,24 +58,17 @@ public class CustomerUtils extends BaseFrameworkSystem {
                        throw new IllegalStateException("Entity manager is closed.");
                }
 
-               // Fake customer instance
-               Customer customer = null;
-
                // Generate number
                String customerNumber = null;
 
                // Default is found
                boolean isFound = true;
 
-               // Declare variables
-               long part1;
-               long part2;
-
                // Is the number used?
                while (isFound) {
                        // Both number parts
-                       part1 = Math.round(Math.random() * 100_000);
-                       part2 = Math.round(Math.random() * 1_000);
+                       long part1 = Math.round(Math.random() * 100_000);
+                       long part2 = Math.round(Math.random() * 1_000);
 
                        // Generate new number
                        customerNumber = String.format("%s-%s", part1, part2); //NOI18N
@@ -83,7 +76,7 @@ public class CustomerUtils extends BaseFrameworkSystem {
                        // Try it
                        try {
                                // Get instance
-                               customer = em.getReference(ShopCustomer.class, customerNumber);
+                               Customer customer = em.getReference(ShopCustomer.class, customerNumber);
                        } catch (final EntityNotFoundException ex) {
                                // Not found
                                isFound = false;