Java Code Examples for java.util.List#removeAll()

The following examples show how to use java.util.List#removeAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
public void safetyCheckForNewFieldsOnTheFeignClientAnnotation() {
	final List<String> methodNames = new ArrayList();
	for (final Method method : FeignClient.class.getMethods()) {
		methodNames.add(method.getName());
	}
	methodNames.removeAll(
			Arrays.asList("annotationType", "value", "serviceId", "qualifier",
					"configuration", "primary", "equals", "hashCode", "toString"));
	Collections.sort(methodNames);
	// If this safety check fails the Builder has to be updated.
	// (1) Either a field was removed from the FeignClient annotation and so it has to
	// be removed
	// on this builder class.
	// (2) Or a new field was added and the builder class has to be extended with this
	// new field.
	assertThat(methodNames).containsExactly("contextId", "decode404", "fallback",
			"fallbackFactory", "name", "path", "url");
}
 
Example 2
/**
 * 移除多个收藏
 *
 * @param removeList
 */
public void removeSome(List<Recommend.RecommendBooks> removeList, boolean removeCache) {
    List<Recommend.RecommendBooks> list = getCollectionList();
    if (list == null) {
        return;
    }
    if (removeCache) {
        for (Recommend.RecommendBooks book : removeList) {
            try {
                // 移除章节文件
                FileUtils.deleteFileOrDirectory(FileUtils.getBookDir(book._id));
                // 移除目录缓存
                CacheManager.getInstance().removeTocList(AppUtils.getAppContext(), book._id);
                // 移除阅读进度
                SettingManager.getInstance().removeReadProgress(book._id);
            } catch (IOException e) {
                LogUtils.e(e.toString());
            }
        }
    }
    list.removeAll(removeList);
    putCollectionList(list);
}
 
Example 3
private static void testFileHandlerClose(File writableDir) throws IOException {
    File fakeLock = new File(writableDir, "log.log.lck");
    if (!createFile(fakeLock, false)) {
        throw new IOException("Can't create fake lock file: " + fakeLock);
    }
    try {
        List<File> before = listLocks(writableDir, true);
        System.out.println("before: " + before.size() + " locks found");
        FileHandler handler = createFileHandler(writableDir);
        System.out.println("handler created: " + handler);
        List<File> after = listLocks(writableDir, true);
        System.out.println("after creating handler: " + after.size() + " locks found");
        handler.close();
        System.out.println("handler closed: " + handler);
        List<File> afterClose = listLocks(writableDir, true);
        System.out.println("after closing handler: " + afterClose.size() + " locks found");
        afterClose.removeAll(before);
        if (!afterClose.isEmpty()) {
            throw new RuntimeException("Zombie lock file detected: " + afterClose);
        }
    } finally {
        if (fakeLock.canRead()) delete(fakeLock);
    }
    List<File> finalLocks = listLocks(writableDir, false);
    System.out.println("After cleanup: " + finalLocks.size() + " locks found");
}
 
Example 4
@Override
public WAL.Entry filter(WAL.Entry entry) {

  //if the WAL.Entry's table isn't System.Catalog or System.Child_Link, it auto-passes this filter
  //TODO: when Phoenix drops support for pre-1.3 versions of HBase, redo as a WALCellFilter
  if (!SchemaUtil.isMetaTable(entry.getKey().getTableName().getName())){
    return entry;
  }

  List<Cell> cells = entry.getEdit().getCells();
  List<Cell> cellsToRemove = Lists.newArrayList();
  for (Cell cell : cells) {
    if (!isTenantRowCell(cell)){
      cellsToRemove.add(cell);
    }
  }
  cells.removeAll(cellsToRemove);
  if (cells.size() > 0) {
    return entry;
  } else {
    return null;
  }
}
 
Example 5
Source Project: TAB   File: PerWorldPlayerlist.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public PacketPlayOutPlayerInfo onPacketSend(ITabPlayer receiver, PacketPlayOutPlayerInfo info) {
	if (info.action != EnumPlayerInfoAction.ADD_PLAYER) return info;
	List<PlayerInfoData> toRemove = new ArrayList<PlayerInfoData>();
	for (PlayerInfoData data : info.entries) {
		ITabPlayer added = Shared.getPlayerByTablistUUID(data.uniqueId);
		if (added != null && !shouldSee(receiver.getBukkitEntity(), added.getBukkitEntity())) {
			toRemove.add(data);
		}
	}
	List<PlayerInfoData> newList = new ArrayList<PlayerInfoData>();
	Arrays.asList(info.entries).forEach(d -> newList.add(d));
	newList.removeAll(toRemove);
	info.entries = newList.toArray(new PlayerInfoData[0]);
	if (info.entries.length == 0) return null;
	return info;
}
 
Example 6
/**
 * Display a chooser to the user.
 * 
 * @param aPc The character the choice is for.
 * @param availableList The list of possible choices.
 * @param selectedList The list of existing selections.
 * @return list The list of the new selections made by the user (unchanged if the dialog was cancelled)
 */
@Override
public List<T> doChooser(PlayerCharacter aPc, final List<T> availableList, final List<T> selectedList,
	final List<String> reservedList)
{
	int effectiveChoices = getNumEffectiveChoices(selectedList, reservedList, aPc);

	boolean dupsAllowed = controller.isMultYes() && controller.isStackYes();

	/*
	 * TODO This is temporarily commented out until the correct behavior of
	 * the "available" list is established. This is done to make
	 * CDOMChoiceManager not remove items when selected, which is consistent
	 * with the (buggy?) old Choose system
	 */
	if (!dupsAllowed)
	{
		// availableList.removeAll(reservedList);
		availableList.removeAll(selectedList);
	}

	Globals.sortChooserLists(availableList, selectedList);

	String title = StringUtils.isBlank(info.getTitle()) ? "in_chooser" //$NON-NLS-1$
		: info.getTitle();
	if (title.startsWith("in_")) //$NON-NLS-1$
	{
		title = LanguageBundle.getString(title);
	}

	CDOMChooserFacadeImpl<T> chooserFacade =
			new CDOMChooserFacadeImpl<>(title, availableList, selectedList, effectiveChoices);
	chooserFacade.setDefaultView(ChooserTreeViewType.NAME);
	chooserFacade.setAllowsDups(dupsAllowed);
	chooserFacade.setInfoFactory(new Gui2InfoFactory(aPc));
	ChooserFactory.getDelegate().showGeneralChooser(chooserFacade);

	return chooserFacade.getFinalSelected();
}
 
Example 7
@Override
protected List<TemporalField> invalidFields() {
    List<TemporalField> list = new ArrayList<>(Arrays.<TemporalField>asList(ChronoField.values()));
    list.removeAll(validFields());
    list.add(JulianFields.JULIAN_DAY);
    list.add(JulianFields.MODIFIED_JULIAN_DAY);
    list.add(JulianFields.RATA_DIE);
    return list;
}
 
Example 8
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
  List list = retValInspector.getList(arguments[0].get());
  List result = Lists.newArrayList();
  if (list != null && !list.isEmpty()) {
    if (primitiveObjectInspector != null
        && primitiveObjectInspector.getPrimitiveCategory() == PrimitiveObjectInspector.PrimitiveCategory.STRING) {
      result = handlerStringArray(list);
    } else {
      result = Lists.newArrayList(list);
      result.removeAll(Collections.singleton(null));
    }
  }
  return result.isEmpty() ? null : result;
}
 
Example 9
private List<Wo> listWithUnitWithType(EffectivePerson effectivePerson, Business business, Wi wi) throws Exception {
	List<Wo> wos = new ArrayList<>();
	List<String> unitIds = new ArrayList<>();
	for (Unit o : business.unit().pick(wi.getUnitList())) {
		if (null != o) {
			unitIds.add(o.getId());
		}
	}
	if (ListTools.isEmpty(unitIds)) {
		return wos;
	}
	List<String> expendUnitIds = business.expendUnitToUnit(unitIds);
	/** 搜索范围不包含自己 */
	expendUnitIds.removeAll(unitIds);
	EntityManager em = business.entityManagerContainer().get(Unit.class);
	CriteriaBuilder cb = em.getCriteriaBuilder();
	CriteriaQuery<String> cq = cb.createQuery(String.class);
	Root<Unit> root = cq.from(Unit.class);
	Predicate p = cb.isMember(wi.getType(), root.get(Unit_.typeList));
	p = cb.and(p, root.get(Unit_.id).in(expendUnitIds));
	List<String> os = em.createQuery(cq.select(root.get(Unit_.id)).where(p).distinct(true)).getResultList();
	List<String> referenceUnitIds = new ArrayList<String>(os);
	for (String str : os) {
		referenceUnitIds.addAll(business.unit().listSupNested(str));
	}
	referenceUnitIds = ListTools.trim(referenceUnitIds, true, true);
	List<Wo> list = Wo.copier.copy(business.entityManagerContainer().list(Unit.class, referenceUnitIds));
	list = business.unit().sort(list);
	this.format(list);
	for (Wo wo : list) {
		if (unitIds.contains(wo.getId())) {
			wos.add(wo);
		}
	}
	return wos;
}
 
Example 10
@Override
public void handleChildChange(String parentPath, List<String> currentChilds)
    throws Exception {
  if (!tryToRefreshCache()) {
    synchronized (_lock) {
      currentChilds.removeAll(KAFKA_INNER_TOPICS);
      LOGGER.info("starting to refresh topic list due to zk child change, currentChilds : {}", currentChilds);
      Set<String> newAddedTopics = new HashSet<>(currentChilds);
      Set<String> currentServingTopics = getAllTopics();
      newAddedTopics.removeAll(currentServingTopics);
      for (String existedTopic : currentServingTopics) {
        if (!currentChilds.contains(existedTopic)) {
          _topicPartitionInfoMap.remove(existedTopic);
        }
      }
      scala.collection.mutable.Map<String, scala.collection.Map<Object, Seq<Object>>> partitionAssignmentForTopics =
          _zkUtils.getPartitionAssignmentForTopics(
              JavaConversions.asScalaBuffer(ImmutableList.copyOf(newAddedTopics)));

      for (String topic : newAddedTopics) {
        try {
          scala.collection.Map<Object, Seq<Object>> partitionsMap =
              partitionAssignmentForTopics.get(topic).get();
          TopicPartition tp = new TopicPartition(topic, partitionsMap.size());
          _topicPartitionInfoMap.put(topic, tp);
        } catch (Exception e) {
          LOGGER.warn("Failed to get topicPartition info for {} from kafka zk: {}", topic, e);
        }
      }
      LOGGER.info("added {} new topics to topic list in zk child change", newAddedTopics.size());
      _kafkaTopicsCounter.inc(_topicPartitionInfoMap.size() - _kafkaTopicsCounter.getCount());
    }
  }
}
 
Example 11
@Test
public final void givenListContainsNulls_whenRemovingNullsWithPlainJavaAlternative_thenCorrect() {
    final List<Integer> list = Lists.newArrayList(null, 1, null);
    list.removeAll(Collections.singleton(null));

    assertThat(list, hasSize(1));
}
 
Example 12
Source Project: kardio   File: AdminServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Function to remove components from list
 */
public List<Component> removeSkippableComponent(List<Component> components) {
	List<Component> removeList = new ArrayList<Component>();
	for (Component component : components) {
		if (skipableInfraComponents.contains(component.getParentComponentName())
				|| skipableInfraComponents.contains(component.getComponentName())) {
			removeList.add(component);
		}
	}
	components.removeAll(removeList);
	return components;
}
 
Example 13
private List<CloudJettyRunner> getOtherAvailableJetties(CloudJettyRunner leader) {
  List<CloudJettyRunner> candidates = new ArrayList<>();
  candidates.addAll(shardToJetty.get("shard1"));

  if (leader != null) {
    candidates.remove(leader);
  }

  candidates.removeAll(nodesDown);

  return candidates;
}
 
Example 14
protected void addSpecialRecipients(List users, Reference ref)
	{
	  //for SiteEmailNotification.getRecipients method doesn't get syllabus' recipients. 
	  //List users = SecurityService.unlockUsers(ability, ref.getReference()); doesn't get users for the site because of permission messing
	  //need add syllabus permission later
		try
		{
			String siteId = (getSite() != null) ? getSite() : ref.getContext();	
			Site site = SiteService.getSite(siteId);
			Set activeUsersIdSet = site.getUsers();
			List activeUsersIdList = new ArrayList(activeUsersIdSet.size());
//			List activeUserList = new Vector();
			Iterator iter = activeUsersIdSet.iterator();
			while(iter.hasNext())
			{
				activeUsersIdList.add((String)iter.next());
			}

			List activeUserList = UserDirectoryService.getUsers(activeUsersIdList);
			activeUserList.removeAll(users);
			for(int i=0; i<activeUserList.size(); i++)
			{
				users.add(activeUserList.get(i));
			}
		}
		catch(Exception e)
		{
			log.error(e.getMessage(), e);
		}
	}
 
Example 15
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryStringVariable() {
  Map<String, Object> vars = new HashMap<String, Object>();
  vars.put("stringVar", "abcdef");
  ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

  vars = new HashMap<String, Object>();
  vars.put("stringVar", "abcdef");
  vars.put("stringVar2", "ghijkl");
  ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

  vars = new HashMap<String, Object>();
  vars.put("stringVar", "azerty");
  ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);

  // Test EQUAL on single string variable, should result in 2 matches
  ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("stringVar", "abcdef");
  List<Execution> executions = query.list();
  assertNotNull(executions);
  assertEquals(2, executions.size());

  // Test EQUAL on two string variables, should result in single match
  query = runtimeService.createExecutionQuery().variableValueEquals("stringVar", "abcdef").variableValueEquals("stringVar2", "ghijkl");
  Execution execution = query.singleResult();
  assertNotNull(execution);
  assertEquals(processInstance2.getId(), execution.getId());

  // Test NOT_EQUAL, should return only 1 execution
  execution = runtimeService.createExecutionQuery().variableValueNotEquals("stringVar", "abcdef").singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(), execution.getId());

  // Test GREATER_THAN, should return only matching 'azerty'
  execution = runtimeService.createExecutionQuery().variableValueGreaterThan("stringVar", "abcdef").singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(), execution.getId());

  execution = runtimeService.createExecutionQuery().variableValueGreaterThan("stringVar", "z").singleResult();
  assertNull(execution);

  // Test GREATER_THAN_OR_EQUAL, should return 3 results
  assertEquals(3, runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("stringVar", "abcdef").count());
  assertEquals(0, runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("stringVar", "z").count());

  // Test LESS_THAN, should return 2 results
  executions = runtimeService.createExecutionQuery().variableValueLessThan("stringVar", "abcdeg").list();
  assertEquals(2, executions.size());
  List<String> expectedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
  List<String> ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
  ids.removeAll(expectedIds);
  assertTrue(ids.isEmpty());

  assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThan("stringVar", "abcdef").count());
  assertEquals(3, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("stringVar", "z").count());

  // Test LESS_THAN_OR_EQUAL
  executions = runtimeService.createExecutionQuery().variableValueLessThanOrEqual("stringVar", "abcdef").list();
  assertEquals(2, executions.size());
  expectedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
  ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
  ids.removeAll(expectedIds);
  assertTrue(ids.isEmpty());

  assertEquals(3, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("stringVar", "z").count());
  assertEquals(0, runtimeService.createExecutionQuery().variableValueLessThanOrEqual("stringVar", "aa").count());

  // Test LIKE
  execution = runtimeService.createExecutionQuery().variableValueLike("stringVar", "azert%").singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(), execution.getId());

  execution = runtimeService.createExecutionQuery().variableValueLike("stringVar", "%y").singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(), execution.getId());

  execution = runtimeService.createExecutionQuery().variableValueLike("stringVar", "%zer%").singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(), execution.getId());

  assertEquals(3, runtimeService.createExecutionQuery().variableValueLike("stringVar", "a%").count());
  assertEquals(0, runtimeService.createExecutionQuery().variableValueLike("stringVar", "%x%").count());

  // Test value-only matching
  execution = runtimeService.createExecutionQuery().variableValueEquals("azerty").singleResult();
  assertNotNull(execution);
  assertEquals(processInstance3.getId(), execution.getId());

  executions = runtimeService.createExecutionQuery().variableValueEquals("abcdef").list();
  assertEquals(2, executions.size());
  expectedIds = Arrays.asList(processInstance1.getId(), processInstance2.getId());
  ids = new ArrayList<String>(Arrays.asList(executions.get(0).getId(), executions.get(1).getId()));
  ids.removeAll(expectedIds);
  assertTrue(ids.isEmpty());

  execution = runtimeService.createExecutionQuery().variableValueEquals("notmatchinganyvalues").singleResult();
  assertNull(execution);

  runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
  runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
  runtimeService.deleteProcessInstance(processInstance3.getId(), "test");
}
 
Example 16
private Future<Boolean> dispatchAssignmentChangeIfNeeded(String connectorType, List<DatastreamTask> assignment,
    boolean isDatastreamUpdate) {
  ConnectorInfo connectorInfo = _connectors.get(connectorType);
  ConnectorWrapper connector = connectorInfo.getConnector();

  List<DatastreamTask> addedTasks = new ArrayList<>(assignment);
  List<DatastreamTask> removedTasks;
  List<DatastreamTask> oldAssignment = _assignedDatastreamTasks.values()
      .stream()
      .filter(t -> t.getConnectorType().equals(connectorType))
      .collect(Collectors.toList());

  // if there are any difference in the list of assignment. Note that if there are no difference
  // between the two lists, then the connector onAssignmentChange() is not called.
  addedTasks.removeAll(oldAssignment);
  oldAssignment.removeAll(assignment);
  removedTasks = oldAssignment;

  if (isDatastreamUpdate || !addedTasks.isEmpty() || !removedTasks.isEmpty()) {
    // Populate the event producers before calling the connector with the list of tasks.
    addedTasks.stream().filter(t -> t.getEventProducer() == null).forEach(this::initializeTask);

    // Dispatch the onAssignmentChange to the connector in a separate thread.
    return _assignmentChangeThreadPool.get(connectorType).submit(() -> {
      try {
        // Send a new copy of assignment to connector to ensure that assignment is not modified.
        // Any modification to assignment object directly will cause discrepancy in the current assignment list.
        connector.onAssignmentChange(new ArrayList<>(assignment));
        // Unassign tasks with producers
        removedTasks.forEach(this::uninitializeTask);
      } catch (Exception ex) {
        _log.warn(String.format("connector.onAssignmentChange for connector %s threw an exception, "
            + "Queuing up a new onAssignmentChange event for retry.", connectorType), ex);
        _eventQueue.put(CoordinatorEvent.createHandleInstanceErrorEvent(ExceptionUtils.getRootCauseMessage(ex)));
        if (isDatastreamUpdate) {
          _eventQueue.put(CoordinatorEvent.createHandleDatastreamChangeEvent());
        } else {
          _eventQueue.put(CoordinatorEvent.createHandleAssignmentChangeEvent());
        }
        return false;
      }
      return true;
    });
  }

  return null;
}
 
Example 17
private List<ViolationContext> extractForwardContext(List<ViolationContext> backwardContexts, EquivalenceClassForEGD equivalenceClass) {
    List<ViolationContext> result = new ArrayList<ViolationContext>(equivalenceClass.getViolationContexts());
    result.removeAll(backwardContexts);
    return result;
}
 
Example 18
private List<ParameterInfo> getNotDeletedInfos(){
	List<ParameterInfo> all= new ArrayList<ParameterInfo>(fParameterInfos);
	all.removeAll(getDeletedInfos());
	return all;
}
 
Example 19
@Override
public Answer compareListAndUpdateInsertDeleteElements(String system, String country, String environement, List<CountryEnvironmentParameters> newList) {
    Answer ans = new Answer(null);

    MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);
    Answer finalAnswer = new Answer(msg1);

    List<CountryEnvironmentParameters> oldList = new ArrayList<>();
    try {
        oldList = this.convert(this.readByVarious(system, country, environement, null));
    } catch (CerberusException ex) {
        LOG.error(ex, ex);
    }

    /**
     * Update and Create all objects database Objects from newList
     */
    List<CountryEnvironmentParameters> listToUpdateOrInsert = new ArrayList<>(newList);
    listToUpdateOrInsert.removeAll(oldList);
    List<CountryEnvironmentParameters> listToUpdateOrInsertToIterate = new ArrayList<>(listToUpdateOrInsert);

    for (CountryEnvironmentParameters objectDifference : listToUpdateOrInsertToIterate) {
        for (CountryEnvironmentParameters objectInDatabase : oldList) {
            if (objectDifference.hasSameKey(objectInDatabase)) {
                ans = this.update(objectDifference);
                finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
                listToUpdateOrInsert.remove(objectDifference);
            }
        }
    }

    /**
     * Delete all objects database Objects that do not exist from newList
     */
    List<CountryEnvironmentParameters> listToDelete = new ArrayList<>(oldList);
    listToDelete.removeAll(newList);
    List<CountryEnvironmentParameters> listToDeleteToIterate = new ArrayList<>(listToDelete);

    for (CountryEnvironmentParameters tcsDifference : listToDeleteToIterate) {
        for (CountryEnvironmentParameters tcsInPage : newList) {
            if (tcsDifference.hasSameKey(tcsInPage)) {
                listToDelete.remove(tcsDifference);
            }
        }
    }
    if (!listToDelete.isEmpty()) {
        ans = this.deleteList(listToDelete);
        finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
    }

    // We insert only at the end (after deletion of all potencial enreg - linked with #1281)
    if (!listToUpdateOrInsert.isEmpty()) {
        ans = this.createList(listToUpdateOrInsert);
        finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
    }
    return finalAnswer;
}
 
Example 20
@Override
protected List<TemporalField> invalidFields() {
    List<TemporalField> list = new ArrayList<>(Arrays.<TemporalField>asList(ChronoField.values()));
    list.removeAll(validFields());
    return list;
}