List of usage examples for java.util ArrayList removeAll
public boolean removeAll(Collection<?> c)
From source file:org.apache.hadoop.hbase.regionserver.compactions.RatioBasedCompactionPolicy.java
/** * @param candidates pre-filtrate/*from w ww .j av a 2s . c o m*/ * @return filtered subset * exclude all bulk load files if configured */ private ArrayList<StoreFile> filterBulk(ArrayList<StoreFile> candidates) { candidates.removeAll(Collections2.filter(candidates, new Predicate<StoreFile>() { @Override public boolean apply(StoreFile input) { return input.excludeFromMinorCompaction(); } })); return candidates; }
From source file:net.sf.housekeeper.domain.inmemory.InMemoryCategoryDAO.java
public List<Category> findAllExcept(Category discardedCategory) { final ArrayList<Category> allCats = new ArrayList<Category>(categories); if (discardedCategory != null) { final List discCats = discardedCategory.getRecursiveCategories(); allCats.removeAll(discCats); }//from www. j a va 2 s .c o m return allCats; }
From source file:de.ks.flatadocdb.defaults.json.SerializationModule.java
@Override public void setupModule(SetupContext context) { context.addBeanSerializerModifier(new BeanSerializerModifier() { @Override// w w w . j a v a2 s . co m public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) { if (metaModel.isRegistered(beanDesc.getBeanClass())) { EntityDescriptor entityDescriptor = metaModel.getEntityDescriptor(beanDesc.getBeanClass()); List<BeanPropertyWriter> relationProperties = beanProperties.stream()// .filter(p -> entityDescriptor.isRelation(p.getMember())).collect(Collectors.toList()); List<BeanPropertyWriter> repoPathProperty = beanProperties.stream()// .filter(p -> p.getAnnotation(PathInRepository.class) != null) .collect(Collectors.toList()); ArrayList<BeanPropertyWriter> all = new ArrayList<>(beanProperties); log.trace("Removing {} relation properties fron {}: {}", relationProperties.size(), beanDesc.getBeanClass(), relationProperties); all.removeAll(relationProperties); all.removeAll(repoPathProperty); relationProperties.stream().map(old -> new RelationCollectionPropertyWriter(old, metaModel)) .forEach(all::add); return all; } else { return beanProperties; } } }); context.addBeanDeserializerModifier(new BeanDeserializerModifier() { @Override public List<BeanPropertyDefinition> updateProperties(DeserializationConfig config, BeanDescription beanDesc, List<BeanPropertyDefinition> propDefs) { if (metaModel.isRegistered(beanDesc.getBeanClass())) { EntityDescriptor entityDescriptor = metaModel.getEntityDescriptor(beanDesc.getBeanClass()); return propDefs.stream()// .filter(p -> !entityDescriptor.isRelation(p.getPrimaryMember()))// .filter(p -> p.getPrimaryMember().getAnnotation(PathInRepository.class) == null)// .collect(Collectors.toList()); } else { return propDefs; } } }); }
From source file:org.svij.taskwarriorapp.fragments.MenuListFragment.java
public void setListView() { data = new TaskDatabase(getActivity()); data.createDataIfNotExist();//from ww w . j av a 2s . co m ArrayList<String> menuCommands = new ArrayList<String>(); menuCommands.addAll(data.getProjects()); if (menuCommands.remove(null)) { menuCommands.add(getString(R.string.no_project)); } menuCommands.removeAll(Collections.singleton(null)); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, menuCommands); setListAdapter(adapter); }
From source file:mt.Tracking.java
public static <P extends AbstractFunction2D<P>> ArrayList<Pair<P, ArrayList<PointFunctionMatch>>> findAllFunctions( final ArrayList<Point> mts, final P function, final double maxError, final int minNumInliers, final int maxDist) { boolean fitted; final ArrayList<Point> remainingPoints = new ArrayList<Point>(); if (mts != null) { remainingPoints.addAll(mts);/* www . ja va2s . c o m*/ final ArrayList<Pair<P, ArrayList<PointFunctionMatch>>> segments = new ArrayList<Pair<P, ArrayList<PointFunctionMatch>>>(); do { fitted = false; final Pair<P, ArrayList<PointFunctionMatch>> f = findFunction(remainingPoints, function.copy(), maxError, minNumInliers, maxDist); if (f != null && f.getB().size() > 0) { fitted = true; segments.add(f); final ArrayList<Point> inlierPoints = new ArrayList<Point>(); for (final PointFunctionMatch p : f.getB()) inlierPoints.add(p.getP1()); remainingPoints.removeAll(inlierPoints); } } while (fitted); return segments; } else return null; }
From source file:org.svij.taskwarriorapp.MenuListFragment.java
public void setListView() { datasource = new TaskDataSource(getActivity()); datasource.createDataIfNotExist();/* w w w . j a v a 2s . c o m*/ ArrayList<String> menuCommands = new ArrayList<String>(); menuCommands.addAll(datasource.getProjects()); if (menuCommands.remove(null)) { menuCommands.add(getString(R.string.no_project)); } menuCommands.removeAll(Collections.singleton(null)); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, menuCommands); setListAdapter(adapter); }
From source file:com.edgenius.wiki.widget.SpaceWidget.java
public Widget invoke(String spaceUname, User viewer) throws WidgetException { Space space = spaceService.getSpaceByUname(spaceUname); SpacePagesModel model = new SpacePagesModel(); if (space == null) { //if space does not exist, return error. throw new WidgetException(ErrorCode.SPACE_NOT_EXIST_ERR); }/*www. j av a 2 s . c om*/ securityService.fillSpaceWikiOperations(viewer, space); try { model.isPrivate = space.isPrivate(); model.widgetStyle = space.getSetting().getWidgetStyle(); if (model.widgetStyle == SpaceSetting.WIDGET_STYLE_ITEM_SHORT_BY_MODIFIED_DATE || model.widgetStyle == SpaceSetting.WIDGET_STYLE_ITEM_SHORT_BY_CREATE_DATE) { int listCount = space.getSetting().getItemAmount(); List<Page> toppages = pageService.getPinTopPages(space.getUid(), spaceUname, viewer); if (toppages != null && toppages.size() > 0) { if (model.widgetStyle == SpaceSetting.WIDGET_STYLE_ITEM_SHORT_BY_CREATE_DATE) { updateModifier(model, toppages); } model.pages = PageUtil.copyPageItem(toppages, listCount); for (PageItemModel item : model.pages) { item.pinTop = true; } } else { //to avoid below code NullPointerException model.pages = new ArrayList<PageItemModel>(); } if (toppages.size() < listCount) { List<Page> pages = rssService.getPagesFromFeed(space.getUid(), spaceUname, viewer); if (model.widgetStyle == SpaceSetting.WIDGET_STYLE_ITEM_SHORT_BY_CREATE_DATE) { updateModifier(model, pages); } if (model.pages.size() > 0) { //merge pin-top pages and rss normal list ArrayList<PageItemModel> rssList = PageUtil.copyPageItem(pages, listCount); //remove duplicated from RSS list and pin-top list rssList.removeAll(model.pages); model.pages.addAll(rssList); int over = model.pages.size() - listCount; if (over > 0) { //pin pages + RSS pages is over list count, then remove oversize from last of list for (int idx = over; idx > 0; idx--) { model.pages.remove(model.pages.size() - 1); } } } else { //only rss normal list model.pages = PageUtil.copyPageItem(pages, listCount); } } model.hidePortrait = space.getSetting().isHidePortrait(); } else if (model.widgetStyle == SpaceSetting.WIDGET_STYLE_HOME_PAGE) { model.page = new PageModel(); Page home = space.getHomepage(); renderService.renderHTML(home); PageUtil.copyPageToModel(home, model.page, userReadingService, null); } model.space = new SpaceModel(); SpaceUtil.copySpaceToModel(space, model.space, viewer, themeService); //copy viewer info: for offline button model.space.viewer = UserUtil.copyUserToModel(viewer, viewer); log.info("Get user " + viewer.getUsername() + " recent pages from space " + spaceUname); } catch (FeedException e) { model.errorCode = ErrorCode.SPACE_RSS_READ_ERROR; //OK, try to recreate this space RSS feed, then user could get it in next time(hope so). rssService.createFeed(spaceUname); } Widget obj = new Widget(); //go to homepage obj.setTitleURL(GwtUtils.getSpacePageToken(spaceUname, null)); obj.setRenderContent(model); return obj; }
From source file:org.paxle.gui.impl.servlets.UserView.java
private void updateUser(UserAdmin userAdmin, User user, HttpServletRequest request, Context context, Key k) throws InvalidSyntaxException, UnsupportedEncodingException { if (user == null) return;/*from w ww .j ava2 s .c o m*/ // getting the http.login name String loginName = request.getParameter(HttpAuthManager.USER_HTTP_LOGIN); /* =========================================================== * USERNAME + PWD * =========================================================== */ // check if the login-name is not empty if (loginName == null || loginName.length() == 0) { String errorMsg = k.get("error.emptyLoginName").toString(); this.logger.warn("The http.login name was empty or null."); context.put(ERROR_MSG, errorMsg); return; } // check if the login name is unique Role[] roles = userAdmin.getRoles(String.format("(%s=%s)", HttpAuthManager.USER_HTTP_LOGIN, loginName)); if (roles != null && (roles.length > 2 || (roles.length == 1 && !roles[0].equals(user)))) { String errorMsg = k.get("error.usernameAlreadyKnown").insert(new String[] { loginName }).toString(); this.logger.warn( String.format("The given login name '%s' is already used by a different user.", loginName)); context.put(ERROR_MSG, errorMsg); return; } // check if the password is typed correctly String pwd1 = request.getParameter(HttpAuthManager.USER_HTTP_PASSWORD); String pwd2 = request.getParameter(HttpAuthManager.USER_HTTP_PASSWORD + "2"); if (pwd1 == null || pwd2 == null || !pwd1.equals(pwd2)) { String errorMsg = k.get("error.invalidPassword").insert(new String[] { loginName }).toString(); this.logger.warn(String.format("The password for login name '%s' was not typed correctly.", loginName)); context.put(ERROR_MSG, errorMsg); return; } // configure http-login data @SuppressWarnings("unchecked") Dictionary<String, Object> props = user.getProperties(); props.put(HttpAuthManager.USER_HTTP_LOGIN, loginName); @SuppressWarnings("unchecked") Dictionary<String, Object> credentials = user.getCredentials(); credentials.put(HttpAuthManager.USER_HTTP_PASSWORD, pwd1); /* =========================================================== * OPEN-ID * =========================================================== */ String openIdURL = request.getParameter("openid.url"); if (openIdURL != null && openIdURL.length() > 0) { // check if URL is unique roles = userAdmin.getRoles(String.format("(openid.url=%s)", openIdURL)); if (roles != null && (roles.length > 2 || (roles.length == 1 && !roles[0].equals(user)))) { String errorMsg = k.get("error.invalidOpenIDURL").insert(new String[] { openIdURL }).toString(); this.logger.warn( String.format("The given OpenID URL '%s' is already used by a different user.", openIdURL)); context.put(ERROR_MSG, errorMsg); return; } // configure the OpenID URL props.put("openid.url", openIdURL); } else { // delete old URL user.getProperties().remove("openid.url"); } /* =========================================================== * LANGUAGE * =========================================================== */ if (request.getParameter(USER_LANGUAGE) != null) { String lang = request.getParameter(USER_LANGUAGE); props.put(USER_LANGUAGE, lang); CookieTool cookies = (CookieTool) context.get("cookieTool"); cookies.add("l10n", lang); } /* =========================================================== * MEMBERSHIP * =========================================================== */ // process membership Authorization auth = userAdmin.getAuthorization(user); String[] currentMembership = auth.getRoles(); if (currentMembership == null) currentMembership = new String[0]; String[] newMembership = request.getParameterValues("membership"); if (newMembership == null) newMembership = new String[0]; // new memberships for (String groupName : newMembership) { if (!auth.hasRole(groupName)) { Role role = userAdmin.getRole(groupName); if (role != null && role.getType() == Role.GROUP) { ((Group) role).addMember(user); } } } // memberships to remove ArrayList<String> oldMemberships = new ArrayList<String>(Arrays.asList(currentMembership)); oldMemberships.removeAll(Arrays.asList(newMembership)); for (String roleName : oldMemberships) { if (auth.hasRole(roleName)) { Role role = userAdmin.getRole(roleName); if (role != null && role.getType() == Role.GROUP) { ((Group) role).removeMember(user); } } } }
From source file:com.dwdesign.tweetings.fragment.UserListMembersFragment.java
private void deleteItem(final long user_id) { final ArrayList<ParcelableUser> data = getData(); final ArrayList<ParcelableUser> users_to_delete = new ArrayList<ParcelableUser>(); for (final ParcelableUser item : data) { if (item.user_id == user_id) { users_to_delete.add(item);//w ww . ja va2 s .c om } } data.removeAll(users_to_delete); getListAdapter().setData(data, true); }
From source file:org.nuclos.common.collection.CollectionUtils.java
/** * Generic version of the org.apache.commons.collections.CollectionUtils.subtract * call.//ww w. j a va2 s .c o m * @param a a collection * @param b a collection * @return a - b, if both are not null, null if a is null, a if b is null */ public static <T> Collection<T> subtract(Collection<T> a, Collection<T> b) { if (a == null) return null; if (b == null) return a; ArrayList<T> r = new ArrayList<T>(a); r.removeAll(b); return r; }