Anonymous avatar Anonymous committed aed5678

more comments and clearer code

Comments (0)

Files changed (1)

src/main/java/com/example/beersupply/ao/BeerRatingServiceImpl.java

         ao.delete(goner);
     }
 
+    /**
+     * Returns an {@code Iterable<String>} of all usernames who have made
+     * a rating on any beer.
+     * @return an {@code Iterable<String>} of usernames
+     */
     @Override
     public Iterable<String> getVotingUsers() {
+        // The primary method for querying ActiveObjects is the ao.find() method,
+        // which takes an entity class object and (optionally) a Query object
+        // specifying column filters.
+//        final Set<String> usernames = new HashSet<String>();
+//
+//        ao.stream(BeerRating.class, Query.select("*"), new EntityStreamCallback<BeerRating, Integer>() {
+//            @Override
+//            public void onRowRead(BeerRating rating) {
+//                usernames.add(rating.getUsername());
+//            }
+//        });
+//
+//        return ImmutableSet.copyOf(usernames);
+        BeerRating[] ratings = ao.find(BeerRating.class);
         final Set<String> usernames = new HashSet<String>();
-
-        ao.stream(BeerRating.class, Query.select("*"), new EntityStreamCallback<BeerRating, Integer>() {
-            @Override
-            public void onRowRead(BeerRating rating) {
-                usernames.add(rating.getUsername());
-            }
-        });
-
-        return ImmutableSet.copyOf(usernames);
+        for (BeerRating rating: ratings) {
+            usernames.add(rating.getUsername());
+        }
+        return usernames;
     }
 
     @Override
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.