List of usage examples for java.util List contains
boolean contains(Object o);
From source file:grails.util.GrailsConfig.java
/** * Configuration Value lookup with thows a GrailsConfigurationException when the value is null * or not within the allowedValues./* w w w . j a va 2s.com*/ * * @param key the flattened key * @param allowedValues List of allowed values * @param <T> the type parameter * @return the value retrieved by ConfigurationHolder.flatConfig */ @SuppressWarnings("unchecked") public static <T> T getMandatory(String key, List<T> allowedValues) { T val = (T) getMandatory(key); if (!allowedValues.contains(val)) { throw new GrailsConfigurationException( String.format("Configuration value for key %s is not one of the allowed values (%s)", key, DefaultGroovyMethods.inspect(allowedValues))); } return val; }
From source file:Main.java
public static void deleteFaces(List<String> faceIdsToDelete, String personId, Context context) { Set<String> faceIds = getAllFaceIds(personId, context); Set<String> newFaceIds = new HashSet<>(); for (String faceId : faceIds) { if (!faceIdsToDelete.contains(faceId)) { newFaceIds.add(faceId);/* w w w . j a va 2s. co m*/ } } SharedPreferences faceIdSet = context.getSharedPreferences(personId + "FaceIdSet", Context.MODE_PRIVATE); SharedPreferences.Editor faceIdSetEditor = faceIdSet.edit(); faceIdSetEditor.putStringSet("FaceIdSet", newFaceIds); faceIdSetEditor.commit(); }
From source file:com.comphenix.xp.parser.Utility.java
public static String formatBoolean(String booleanName, List<Boolean> value) { // Mirror the query syntax if (value == null || value.isEmpty() || value.contains(null)) return ""; else/* ww w . j a v a 2s.co m*/ return value.get(0) ? booleanName : "!" + booleanName; }
From source file:Main.java
/** * check equal without caring about the order. *//*from w w w .ja v a 2 s .com*/ public static <T> boolean isEqualList(List<T> list1, List<T> list2) { if (list1 == list2) { return true; } if (list1 == null || list2 == null || list1.size() != list2.size()) { return false; } for (T obj1 : list1) { if (!list2.contains(obj1)) { return false; } } return true; }
From source file:Main.java
/** * Determines whether the provided {@link View} and {@link AccessibilityNodeInfoCompat} is a * top-level item in a scrollable container. * * @param view The {@link View} to evaluate * @param node The {@link AccessibilityNodeInfoCompat} to evaluate * @return {@code true} if it is a top-level item in a scrollable container. *///from w w w . ja v a2 s. c o m public static boolean isTopLevelScrollItem(@Nullable AccessibilityNodeInfoCompat node, @Nullable View view) { if (node == null || view == null) { return false; } View parent = (View) ViewCompat.getParentForAccessibility(view); if (parent == null) { return false; } if (node.isScrollable()) { return true; } List actionList = node.getActionList(); if (actionList.contains(AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) || actionList.contains(AccessibilityNodeInfoCompat.ACTION_SCROLL_BACKWARD)) { return true; } // AdapterView, ScrollView, and HorizontalScrollView are focusable // containers, but Spinner is a special case. if (parent instanceof Spinner) { return false; } return parent instanceof AdapterView || parent instanceof ScrollView || parent instanceof HorizontalScrollView; }
From source file:Main.java
public static String[] filterFloor(List<String> longRoomList, String buildingNumber, String prefix) { /**//*from w ww . ja va 2 s .c om*/ if (longRoomList == null) { return null; } List<String> floor_info = new ArrayList<String>(); for (int i = 0; i < longRoomList.size(); ++i) { String[] slice = longRoomList.get(i).split("-"); if (slice.length == 4 && slice[0].equals(buildingNumber) && !floor_info.contains(prefix + slice[1])) { floor_info.add(prefix + slice[1]); } } return listToArray(floor_info); }
From source file:Main.java
/** * Compares the given two {@link List} and returns {@code true} if they both contains the same * elements, no matter what their respective order. * //w w w . ja v a 2s . co m * @param left the left-hand side {@link List} to compare * @param right the right-hand side {@link List} to compare * @param <T> the elements type * @return {@code true} if they have the same elements, {@code false} otherwise (including * different size and {@code null} lists) */ public static <T> boolean equivalent(final List<T> left, final List<T> right) { if (left == null || right == null) { return false; } if (left.size() != right.size()) { return false; } for (T element : left) { if (!right.contains(element)) { return false; } } return true; }
From source file:Main.java
/** * add all distinct entry to list1 from list2 * /* ww w. ja v a 2 s . com*/ * @param <V> * @param sourceList * @param entryList * @return the count of entries be added */ public static <V> int addDistinctList(List<V> sourceList, List<V> entryList) { if (sourceList == null || isEmpty(entryList)) { return 0; } int sourceCount = sourceList.size(); for (V entry : entryList) { if (!sourceList.contains(entry)) { sourceList.add(entry); } } return sourceList.size() - sourceCount; }
From source file:Main.java
public static void fillLeftList(String[] pairsList, List<String> namesList, ArrayAdapter<String> adapter) { String[] names;/*from w ww . j ava 2 s .c om*/ if (pairsList.length != 0) { namesList.clear(); for (String s : pairsList) { names = s.split("-"); if (!namesList.contains(names[0])) { namesList.add(names[0]); } } if (adapter != null) { adapter.notifyDataSetChanged(); } } }
From source file:controllers.group.GroupMsgApp.java
/** * ???/*from w w w . j a v a 2 s . c o m*/ * @return * @throws IOException */ @Transactional public static Result agreeApply() throws IOException { User currentUser = User.getFromSession(session()); ObjectNodeResult result = new ObjectNodeResult(); Long groupId = new Long(request().getQueryString("groupId")); Long userId = new Long(request().getQueryString("userId")); Long messageId = new Long(request().getQueryString("messageId")); Group group = Group.queryGroupById(groupId); if (group == null) return ok(result.errorkey("group.error.nofound").getObjectNode()); User recevierUser = User.findById(userId); List<User> userList = Group.queryUserListOfGroup(groupId); // ? if (!userList.contains(recevierUser)) { // ? ChatService.appendMemberToGroup(groupId, userId); MessageService.pushMsgApplyAgree(currentUser, recevierUser, group); MessageService.handlerMessage(messageId); } else { MessageService.handlerMessage(messageId); return ok(result.error("?.").getObjectNode()); } return ok(result.getObjectNode()); }