List of usage examples for java.util ArrayList equals
public boolean equals(Object o)
From source file:sonata.kernel.vimadaptor.IpNetPoolTest.java
/** * Try a double allocation. Get the same * //from w w w . j ava 2 s. c om * */ @Test public void testReserveSubnetRangeTwice() { pool = VimNetTable.getInstance().getNetPool("1111-1111"); int numOfSubnet = 100; String instanceUuid1 = UUID.randomUUID().toString(); ArrayList<String> myPool = pool.reserveSubnets(instanceUuid1, numOfSubnet); Assert.assertNotNull("Reservation gave unexpected null result.", myPool); ArrayList<String> mySecondPool = pool.reserveSubnets(instanceUuid1, numOfSubnet); Assert.assertNotNull("Second reservation gave unexpected null result.", mySecondPool); Assert.assertTrue("The two reservation should be equals. They are not.", myPool.equals(mySecondPool)); }
From source file:net.reichholf.dreamdroid.fragment.MovieListFragment.java
@Override public void onMultiChoiceDialogSelection(String dialogTag, DialogInterface dialog, Integer[] selected) { ArrayList<String> tags = DreamDroid.getTags(); ArrayList<String> selectedTags = new ArrayList<>(); for (Integer which : selected) { selectedTags.add(tags.get(which)); }// ww w.j a v a 2s . c o m mTagsChanged = !selectedTags.equals(mSelectedTags); mSelectedTags = selectedTags; }
From source file:com.woxthebox.draglistview.sample.GameActivity.java
public boolean isCorrect() { ArrayList<String> correctAnswer = new ArrayList<String>(); switch (whichStage % 6) { case 1://from w w w . ja v a 2s . co m correctAnswer.add("stepForward();"); if (correctAnswer.equals(BoardFragment.methodValuesRight)) { Toast.makeText(GameActivity.this, "You are correct! Great job!", Toast.LENGTH_LONG).show(); bt.sendMessage("1"); } else Toast.makeText(GameActivity.this, "You are incorrect! Please try again!", Toast.LENGTH_LONG).show(); return true; case 2: ArrayList<String> correctAnswer2 = new ArrayList<String>(); correctAnswer2.add("stepForward();"); correctAnswer2.add("stepForward();"); correctAnswer2.add("turnLeft();"); if (correctAnswer2.equals(BoardFragment.methodValuesRight)) { Toast.makeText(GameActivity.this, "You are correct! Great job!", Toast.LENGTH_LONG).show(); bt.sendMessage("2"); } else Toast.makeText(GameActivity.this, "You are incorrect! Please try again!", Toast.LENGTH_LONG).show(); case 3: ArrayList<String> correctAnswer3 = new ArrayList<String>(); correctAnswer3.add("for(i=0; i<5; i++){"); correctAnswer3.add("stepForward();"); correctAnswer3.add("}"); if (correctAnswer3.equals(BoardFragment.methodValuesRight)) { bt.sendMessage("3"); Toast.makeText(GameActivity.this, "You are correct! Great job!", Toast.LENGTH_LONG).show(); } else Toast.makeText(GameActivity.this, "You are incorrect! Please try again!", Toast.LENGTH_LONG).show(); case 4: ArrayList<String> correctAnswer4 = new ArrayList<String>(); correctAnswer4.add("for(i=0; i<4; i++){"); correctAnswer4.add("stepForward();"); correctAnswer4.add("}"); correctAnswer4.add("for(i=0; i<4; i++){"); correctAnswer4.add("stepBackward();"); correctAnswer4.add("}"); if (correctAnswer4.equals(BoardFragment.methodValuesRight)) { bt.sendMessage("4"); Toast.makeText(GameActivity.this, "You are correct! Great job!", Toast.LENGTH_LONG).show(); } else Toast.makeText(GameActivity.this, "You are incorrect! Please try again!", Toast.LENGTH_LONG).show(); case 5: ArrayList<String> correctAnswer5 = new ArrayList<String>(); correctAnswer5.add("for(i=0; i<5; i++){"); correctAnswer5.add("stepForward();"); correctAnswer5.add("}"); correctAnswer5.add("for(i=0; i<2; i++){"); correctAnswer5.add("stepBackward();"); correctAnswer5.add("}"); correctAnswer5.add("turnLeft();"); if (correctAnswer5.equals(BoardFragment.methodValuesRight)) { bt.sendMessage("5"); Toast.makeText(GameActivity.this, "You are correct! Great job!", Toast.LENGTH_LONG).show(); } else Toast.makeText(GameActivity.this, "You are incorrect! Please try again!", Toast.LENGTH_LONG).show(); case 6: ArrayList<String> correctAnswer6 = new ArrayList<String>(); // correctAnswer6.add("for(i=0; i<2; i++){"); correctAnswer6.add("for(i=0; i<3; i++){"); correctAnswer6.add("stepForward();"); correctAnswer6.add("turnRight();"); // correctAnswer6.add("}"); correctAnswer6.add("}"); if (correctAnswer6.equals(BoardFragment.methodValuesRight)) { bt.sendMessage("6"); Toast.makeText(GameActivity.this, "You are correct! Great job!", Toast.LENGTH_LONG).show(); } else Toast.makeText(GameActivity.this, "You are incorrect! Please try again!", Toast.LENGTH_LONG).show(); } return false; }
From source file:org.apache.cassandra.locator.ReplicationStrategyEndpointCacheTest.java
public void runCacheRespectsTokenChangesTest(Class stratClass, Map<String, String> configOptions) throws Exception { setup(stratClass, configOptions);// w ww . j a v a2s . c o m ArrayList<InetAddress> initial; ArrayList<InetAddress> endpoints; endpoints = strategy.getNaturalEndpoints(searchToken); assert endpoints.size() == 5 : StringUtils.join(endpoints, ","); // test token addition, in DC2 before existing token initial = strategy.getNaturalEndpoints(searchToken); tmd.updateNormalToken(new BigIntegerToken(String.valueOf(35)), InetAddress.getByName("127.0.0.5")); endpoints = strategy.getNaturalEndpoints(searchToken); assert endpoints.size() == 5 : StringUtils.join(endpoints, ","); assert !endpoints.equals(initial); // test token removal, newly created token initial = strategy.getNaturalEndpoints(searchToken); tmd.removeEndpoint(InetAddress.getByName("127.0.0.5")); endpoints = strategy.getNaturalEndpoints(searchToken); assert endpoints.size() == 5 : StringUtils.join(endpoints, ","); assert !endpoints.contains(InetAddress.getByName("127.0.0.5")); assert !endpoints.equals(initial); // test token change initial = strategy.getNaturalEndpoints(searchToken); //move .8 after search token but before other DC3 tmd.updateNormalToken(new BigIntegerToken(String.valueOf(25)), InetAddress.getByName("127.0.0.8")); endpoints = strategy.getNaturalEndpoints(searchToken); assert endpoints.size() == 5 : StringUtils.join(endpoints, ","); assert !endpoints.equals(initial); }
From source file:com.clust4j.algo.NNHSTests.java
License:asdf
private static int differenceInIdxArrays(int[] expected, int[] actual) { // Check to see if the diff is <= 2 ArrayList<Integer> aa = new ArrayList<Integer>(); ArrayList<Integer> bb = new ArrayList<Integer>(); for (int in : expected) aa.add(in);//from www . jav a 2s .c o m for (int in : actual) bb.add(in); ArrayList<Integer> larger = aa.size() > bb.size() ? aa : bb; ArrayList<Integer> smaller = aa.equals(larger) ? bb : aa; larger.removeAll(smaller); return larger.size(); }
From source file:ece356.UserDBAO.java
public static ArrayList<DoctorData> queryDoctor(HashMap<String, String> doctorParam, String user) throws ClassNotFoundException, SQLException { Connection con = null;//from www . j a v a 2 s . c o m PreparedStatement pstmt = null; ArrayList<DoctorData> ret; try { con = getConnection(); String query; boolean reviewByFriends = false; if (doctorParam.containsKey("reviewByFriends")) { if (doctorParam.get("reviewByFriends").equals("yes")) { query = "select * from doctorSearchView where username in (select username from doctorSearchView left join review on doctorSearchView.doc_spec_username = review.doc_username where doctorSearchView.patient_username in " + "(select friend.sent_username as friend " + "from friend where friend.isAccepted = 1 AND friend.recieved_username like '%" + user + "%'" + "union " + "select friend.recieved_username as friend " + "from friend where friend.isAccepted = 1 AND friend.sent_username like '%" + user + "%'))"; reviewByFriends = true; } else { query = "SELECT * FROM doctorSearchView "; } doctorParam.remove("reviewByFriends"); } else { query = "SELECT * FROM doctorSearchView "; //pstmt = con.prepareStatement(query); } // Query for general doctor information ArrayList<String> keys = new ArrayList<String>(doctorParam.keySet()); ArrayList<String> values = new ArrayList<String>(doctorParam.values()); HashMap<Integer, Integer> h1 = new HashMap<>(); int counter = 0; if (!keys.isEmpty()) { counter++; if (!reviewByFriends) query = query + " where"; else query = query + " AND"; for (String key : keys) { if (key.equals("averageRating") || key.equals("yearsLicensed")) { query = query + " " + key + " >= ?"; query += " AND"; h1.put(counter, counter); } else if (key.equals("gender")) { query = query + " " + key + " = ?"; query += " AND"; h1.put(counter, counter); } else if (keys.equals("reviewByFriends")) { } else { query = query + " " + key + " LIKE ?"; query += " AND"; } counter++; } query = query.substring(0, query.length() - 4); System.out.println(query); } query += " group by first_name, last_name, gender, averageRating, numberOfReviews"; pstmt = con.prepareStatement(query); if (!values.isEmpty()) { counter = 1; for (String value : values) { if (h1.containsKey(counter)) { pstmt.setString(counter, value); } else { pstmt.setString(counter, "%" + value + "%"); } counter++; } } System.out.println(pstmt); ResultSet resultSet; resultSet = pstmt.executeQuery(); ret = new ArrayList(); while (resultSet.next()) { DoctorData doctor = new DoctorData(); doctor.userName = resultSet.getString("username"); doctor.firstName = resultSet.getString("first_name"); doctor.middleInitial = resultSet.getString("middle_initial"); doctor.lastName = resultSet.getString("last_name"); doctor.gender = resultSet.getString("gender"); doctor.averageRating = resultSet.getDouble("averageRating"); doctor.numberOfReviews = resultSet.getInt("numberOfReviews"); ret.add(doctor); } return ret; } catch (Exception e) { System.out.println("EXCEPTION:%% " + e); } finally { if (pstmt != null) { pstmt.close(); } if (con != null) { con.close(); } } return null; }
From source file:net.reichholf.dreamdroid.fragment.TimerEditFragment.java
@Override public void onMultiChoiceDialogSelection(String dialogTag, DialogInterface dialog, Integer[] selected) { if ("dialog_select_tags".equals(dialogTag)) { ArrayList<String> tags = DreamDroid.getTags(); ArrayList<String> selectedTags = new ArrayList<>(); for (Integer which : selected) { selectedTags.add(tags.get(which)); }/* ww w . j ava 2 s. co m*/ mTagsChanged = !selectedTags.equals(mSelectedTags); mSelectedTags = selectedTags; } else if ("dialog_select_repeatings".equals(dialogTag)) { for (int i = 0; i < mCheckedDays.length; ++i) { mCheckedDays[i] = false; } for (Integer which : selected) { mCheckedDays[which] = true; } String text = setRepeated(mCheckedDays, mTimer); mRepeatings.setText(text); } }
From source file:de.spiritcroc.modular_remote.MainActivity.java
public void orderPages(List<Integer> order) { ArrayList<PageContainerFragment> pages = new ArrayList<>(); for (int i = 0; i < this.pages.size(); i++) { int index = order.indexOf(i); if (index < 0 || index >= this.pages.size()) { Log.e(LOG_TAG, "orderPages: illegal index " + index + " for page " + i); return; }//from w w w. ja v a 2s . c o m pages.add(this.pages.get(index)); } if (pages.equals(this.pages)) { return; } PageContainerFragment currentPage = this.pages.get(viewPager.getCurrentItem()); this.pages = pages; notifyDataSetChanged(); restart(pages.indexOf(currentPage)); }
From source file:br.unicamp.cst.behavior.bn.Behavior.java
public synchronized boolean changedWorldBeliefState() { ArrayList<Object> temp1 = new ArrayList<Object>(); ArrayList<Object> temp2 = new ArrayList<Object>(); temp1.addAll(listOfWorldBeliefStates); temp2.addAll(listOfPreviousWorldBeliefStates); return (!temp1.equals(temp2)); }
From source file:configuration.Util.java
public static boolean equalArrayLists(ArrayList<String> one, ArrayList<String> two) { if (one == null && two == null) { return true; }//www . j a v a 2 s .co m if ((one == null && two != null) || one != null && two == null || one.size() != two.size()) { return false; } //to avoid messing the order of the lists we will use a copy //as noted in comments by A. R. S. one = new ArrayList<String>(one); two = new ArrayList<String>(two); Collections.sort(one); Collections.sort(two); return one.equals(two); }