当前位置: 首页>>代码示例>>Java>>正文


Java IteratorUtils.toList方法代码示例

本文整理汇总了Java中org.apache.commons.collections4.IteratorUtils.toList方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorUtils.toList方法的具体用法?Java IteratorUtils.toList怎么用?Java IteratorUtils.toList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.collections4.IteratorUtils的用法示例。


在下文中一共展示了IteratorUtils.toList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findAll

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Override
public Page<T> findAll(final Set<T> groups, final String criteria, final Pageable pageable, final Map<String, Comparator<T>> customComparators) {
	// Create the set with the right comparator
	final List<Sort.Order> orders = IteratorUtils.toList(ObjectUtils.defaultIfNull(pageable.getSort(), new ArrayList<Sort.Order>()).iterator());
	orders.add(DEFAULT_ORDER);
	final Sort.Order order = orders.get(0);
	Comparator<T> comparator = customComparators.get(order.getProperty());
	if (order.getDirection() == Direction.DESC) {
		comparator = Collections.reverseOrder(comparator);
	}
	final Set<T> result = new TreeSet<>(comparator);

	// Filter the groups, filtering by the criteria
	addFilteredByPattern(groups, criteria, result);

	// Apply in-memory pagination
	return inMemoryPagination.newPage(result, pageable);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:19,代码来源:AbstractContainerLdaRepository.java

示例2: receiveLocked

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
 * Just received a locked message. Must acknowledge it.
 * 
 * @param from
 *            The node that sent the locked message.
 * @param to
 *            The node that must acknowledge the locked message.
 */
private void receiveLocked(Node from, Node to) {
	MUnlockBroadcast mu = new MUnlockBroadcast(from, to);
	Transport t = ((Transport) this.node.getProtocol(FastConfig.getTransport(PreventiveCausalBroadcast.pid)));

	APeerSampling ps = (APeerSampling) this.node.getProtocol(FastConfig.getLinkable(PreventiveCausalBroadcast.pid));
	List<Node> neighborhood = IteratorUtils.toList(ps.getAliveNeighbors().iterator());

	if (neighborhood.contains(from)) {
		t.send(this.node, from, mu, PreventiveCausalBroadcast.pid);
	} else {
		// just to check if it cannot send message because it has no
		PreventiveCausalBroadcast fcb = (PreventiveCausalBroadcast) from.getProtocol(PreventiveCausalBroadcast.pid);
		if (fcb.buffers.containsKey(to)) {
			System.out.println("NOT COOL");
		}
	}
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:26,代码来源:PreventiveCausalBroadcast.java

示例3: ProjectConfigurationBuilder

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
public ProjectConfigurationBuilder(ProjectConfiguration projectConfiguration) {
    if (projectConfiguration == null) {
        admins = new ArrayList<>();
        users = new ArrayList<>();
        stackConfigurations = new HashSet<>();

    } else {
        identifier = projectConfiguration.getIdentifier();
        entityIdentifier = projectConfiguration.getEntityIdentifier();
        name = projectConfiguration.getName();
        userService = projectConfiguration.getUserService();
        admins = IteratorUtils.toList(projectConfiguration.getTeamLeaders());
        users = IteratorUtils.toList(projectConfiguration.getUsers());
        stackConfigurations = new HashSet<>(projectConfiguration.getStackConfigurations());
    }
}
 
开发者ID:kodokojo,项目名称:kodokojo,代码行数:17,代码来源:ProjectConfigurationBuilder.java

示例4: createRegisterSerialisationFormat_returnsRSFFromEntireRegister

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Test
public void createRegisterSerialisationFormat_returnsRSFFromEntireRegister() {
    when(register.getItemIterator()).thenReturn(Arrays.asList(item1, item2).iterator());
    when(register.getDerivationEntryIterator(IndexFunctionConfiguration.IndexNames.METADATA)).thenReturn(Collections.emptyIterator());
    when(register.getEntryIterator()).thenReturn(Arrays.asList(entry1, entry2).iterator());

    RegisterProof expectedRegisterProof = new RegisterProof(new HashValue(HashingAlgorithm.SHA256, "1231234"), 46464);
    when(register.getRegisterProof()).thenReturn(expectedRegisterProof);

    RegisterSerialisationFormat actualRSF = sutCreator.create(register);
    List<RegisterCommand> actualCommands = IteratorUtils.toList(actualRSF.getCommands());

    verify(register, times(1)).getItemIterator();
    verify(register, times(1)).getEntryIterator();
    verify(register, times(1)).getRegisterProof();

    assertThat(actualCommands.size(), equalTo(6));
    assertThat(actualCommands, contains(
            assertEmptyRootHashCommand,
            addItem1Command,
            addItem2Command,
            appendEntry1Command,
            appendEntry2Command,
            new RegisterCommand("assert-root-hash", Collections.singletonList("sha-256:1231234"))
    ));
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:27,代码来源:RSFCreatorTest.java

示例5: createRegisterSerialisationFormat_returnsRSFFromEntireIndex

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Test
public void createRegisterSerialisationFormat_returnsRSFFromEntireIndex() {
    when(register.getItemIterator()).thenReturn(Arrays.asList(item1, item2).iterator());
    when(register.getDerivationEntryIterator(IndexNames.METADATA)).thenReturn(Collections.emptyIterator());
    when(register.getDerivationEntryIterator("index")).thenReturn(Arrays.asList(entry1, entry2).iterator());

    RegisterSerialisationFormat actualRSF = sutCreator.create(register, "index");
    List<RegisterCommand> actualCommands = IteratorUtils.toList(actualRSF.getCommands());

    verify(register, times(1)).getItemIterator();
    verify(register, times(1)).getDerivationEntryIterator("index");

    assertThat(actualCommands.size(), equalTo(5));
    assertThat(actualCommands, contains(
            assertEmptyRootHashCommand,
            addItem1Command,
            addItem2Command,
            appendEntry1Command,
            appendEntry2Command
    ));
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:22,代码来源:RSFCreatorTest.java

示例6: createRegisterSerialisationFormat_whenCalledWithBoundary_returnsPartialRSFRegister

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Test
public void createRegisterSerialisationFormat_whenCalledWithBoundary_returnsPartialRSFRegister() {
    RegisterProof oneEntryRegisterProof = new RegisterProof(new HashValue(HashingAlgorithm.SHA256, "oneEntryInRegisterHash"), 1);
    RegisterProof twoEntriesRegisterProof = new RegisterProof(new HashValue(HashingAlgorithm.SHA256, "twoEntriesInRegisterHash"), 2);

    when(register.getItemIterator(1, 2)).thenReturn(Collections.singletonList(item1).iterator());
    when(register.getEntryIterator(1, 2)).thenReturn(Collections.singletonList(entry1).iterator());
    when(register.getRegisterProof(1)).thenReturn(oneEntryRegisterProof);
    when(register.getRegisterProof(2)).thenReturn(twoEntriesRegisterProof);

    RegisterSerialisationFormat actualRSF = sutCreator.create(register, 1, 2);
    List<RegisterCommand> actualCommands = IteratorUtils.toList(actualRSF.getCommands());

    verify(register, times(1)).getItemIterator(1, 2);
    verify(register, times(1)).getEntryIterator(1, 2);

    assertThat(actualCommands.size(), equalTo(4));
    assertThat(actualCommands, contains(
            new RegisterCommand("assert-root-hash", Collections.singletonList(oneEntryRegisterProof.getRootHash().encode())),
            addItem1Command,
            appendEntry1Command,
            new RegisterCommand("assert-root-hash", Collections.singletonList(twoEntriesRegisterProof.getRootHash().encode()))
    ));
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:25,代码来源:RSFCreatorTest.java

示例7: createRegisterSerialisationFormat_throwsAnExceptionForUnknownMapperType

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Test
public void createRegisterSerialisationFormat_throwsAnExceptionForUnknownMapperType() throws Exception {
    when(register.getItemIterator()).thenReturn(Arrays.asList(item1, item2).iterator());
    when(register.getDerivationEntryIterator(IndexFunctionConfiguration.IndexNames.METADATA)).thenReturn(Collections.emptyIterator());
    when(register.getEntryIterator()).thenReturn(Arrays.asList(entry1, entry2).iterator());

    RegisterProof expectedRegisterProof = new RegisterProof(new HashValue(HashingAlgorithm.SHA256, "1231234"), 28828);
    when(register.getRegisterProof()).thenReturn(expectedRegisterProof);

    expectedException.expect(RuntimeException.class);
    expectedException.expectMessage("Mapper not registered for class: uk.gov.register.util.HashValue");

    RSFCreator creatorWithoutMappers = new RSFCreator();
    RegisterSerialisationFormat rsf = creatorWithoutMappers.create(register);
    IteratorUtils.toList(rsf.getCommands());
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:17,代码来源:RSFCreatorTest.java

示例8: getOnceTupleDefs

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
 * Returns the set of once-only tuple definitions for this combiner.
 */
private Set<Tuple> getOnceTupleDefs( final List<VarDef> combinedVars)
  {
  try
    {
    return
      new HashSet<Tuple>
      ( IteratorUtils.toList
        ( IteratorUtils.transformedIterator
          ( getOnceTuples(),
            new Transformer<TupleRef,Tuple>()
              {
              public Tuple transform( TupleRef tupleRef)
                {
                return toTuple( combinedVars, tupleRef);
                }
              })));
    }
  catch( Exception e)
    {
    throw new IllegalStateException( "Invalid once-only tuple definition", e);
    }
  }
 
开发者ID:Cornutum,项目名称:tcases,代码行数:26,代码来源:TupleCombiner.java

示例9: getTests_FromBaseTests_Same

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Test
public void getTests_FromBaseTests_Same()
  {
  // Given...
  SystemInputDef systemInputDef = systemInputResources_.read( "system-input-def-4.xml");
  FunctionInputDef functionInputDef = systemInputDef.getFunctionInputDef( "Make");
  TupleGenerator generator = new TupleGenerator();

  generator.addCombiner
    ( new TupleCombiner(2)
      .addIncludedVar( "Shape")
      .addIncludedVar( "Size"));
  
  // When...
  FunctionTestDef baseTestDef = generator.getTests( functionInputDef, null);
  FunctionTestDef functionTestDef = generator.getTests( functionInputDef, baseTestDef);

  // Expect...
  List<TestCase> expectedTestCases = IteratorUtils.toList( baseTestDef.getTestCases());
  List<TestCase> actualTestCases = IteratorUtils.toList( functionTestDef.getTestCases());
  assertSetEquals( "When base tests same", expectedTestCases, actualTestCases);
  }
 
开发者ID:Cornutum,项目名称:tcases,代码行数:23,代码来源:TestTupleGenerator.java

示例10: getTuplesIncluded

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
 * If <CODE>included</CODE> is true, returns the subset of the given set of tuples that are included in at least one test case
 * from the given test definition.
 *
 * Otherwise, if <CODE>included</CODE> is false, returns the subset of the given set of tuples that are not included in any test case.
 */
private static Collection<Tuple> getTuplesIncluded( Collection<Tuple> tuples, final FunctionTestDef testDef, final boolean included)
  {
  return
    IteratorUtils.toList
    ( IteratorUtils.filteredIterator
      ( tuples.iterator(),
        new Predicate<Tuple>()
          {
          public boolean evaluate( final Tuple tuple)
            {
            return
              IteratorUtils.filteredIterator
              ( testDef.getTestCases(),
                new Predicate<TestCase>()
                {
                public boolean evaluate( TestCase testCase)
                  {
                  return testCaseIncludes( testCase, tuple);
                  }
                })
              .hasNext() == included;
            }
          }));
    }
 
开发者ID:Cornutum,项目名称:tcases,代码行数:31,代码来源:AssertTestDef.java

示例11: getMapCollection

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
  * INTERNAL: Wraps a QueryResultIF instance in a suitable
  * MapCollection implementation.
  */ 
 protected Collection getMapCollection(QueryResultIF result) {

   if (select != null) {
     int index = result.getIndex(select);
     if (index < 0)
throw new IndexOutOfBoundsException("No query result column named '" + select + "'");

     List list = new ArrayList();
     while (result.next())
       list.add(result.getValue(index));
     result.close();
     return list;
   }

   if (result instanceof net.ontopia.topicmaps.query.impl.basic.QueryResult)
     // BASIC
     return net.ontopia.topicmaps.query.impl.basic.QueryResultWrappers.getWrapper(result);
   else {
     // FIXME: Should pass collection size if available.
     return IteratorUtils.toList(new QueryResultIterator(result));
   }
 }
 
开发者ID:ontopia,项目名称:ontopia,代码行数:27,代码来源:TologQueryTag.java

示例12: testValuesSmallerThanOrEqual

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
public void testValuesSmallerThanOrEqual() {
  assertFalse(ix.getValuesSmallerThanOrEqual("").hasNext());
  
  builder.makeOccurrence(builder.makeTopic(), builder.makeTopic(), "a");
  builder.makeOccurrence(builder.makeTopic(), builder.makeTopic(), "b");
  builder.makeOccurrence(builder.makeTopic(), builder.makeTopic(), "c");
  
  List<String> values = IteratorUtils.toList(ix.getValuesSmallerThanOrEqual("c"));
  
  assertEquals(3, values.size());
  assertTrue(values.contains("a"));
  assertTrue(values.contains("b"));
  assertTrue(values.contains("c"));

  values = IteratorUtils.toList(ix.getValuesSmallerThanOrEqual("a"));
  assertEquals(1, values.size());
  assertTrue(values.contains("a"));
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:19,代码来源:OccurrenceIndexTest.java

示例13: getOccurrences

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
protected Collection<?> getOccurrences(String value, String datatype) {
	OccurrenceIndexIF index = getIndex(OccurrenceIndexIF.class);
	
	try {
		switch (getAttribute("type").toUpperCase()) {
			case "VALUE":
				if (datatype == null) return index.getOccurrences(value);
				else return index.getOccurrences(value, new URILocator(datatype));
			case "PREFIX":
				if (value == null) throw OntopiaRestErrors.MANDATORY_ATTRIBUTE_IS_NULL.build("value", "String");
				if (datatype == null) return index.getOccurrencesByPrefix(value);
				else return index.getOccurrencesByPrefix(value, new URILocator(datatype));
			case "GTE": return IteratorUtils.toList(index.getValuesGreaterThanOrEqual(value));
			case "LTE": return IteratorUtils.toList(index.getValuesSmallerThanOrEqual(value));

			default: 
				setStatus(Status.CLIENT_ERROR_NOT_FOUND, TYPE_ERROR_MESSAGE);
				return null;
		}
	} catch (MalformedURLException mufe) {
		throw OntopiaRestErrors.MALFORMED_LOCATOR.build(mufe, datatype);
	}
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:24,代码来源:IndexResource.java

示例14: findAll

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
@Override
public Page<UserOrg> findAll(final Collection<GroupOrg> requiredGroups, final Set<String> companies, final String criteria,
		final Pageable pageable) {
	// Create the set with the right comparator
	final List<Sort.Order> orders = IteratorUtils.toList(ObjectUtils.defaultIfNull(pageable.getSort(), new ArrayList<Sort.Order>()).iterator());
	orders.add(DEFAULT_ORDER);
	final Sort.Order order = orders.get(0);
	Comparator<UserOrg> comparator = ObjectUtils.defaultIfNull(COMPARATORS.get(order.getProperty()), DEFAULT_COMPARATOR);
	if (order.getDirection() == Direction.DESC) {
		comparator = Collections.reverseOrder(comparator);
	}
	final Set<UserOrg> result = new TreeSet<>(comparator);

	// Filter the users traversing firstly the required groups and their members, the companies, then the criteria
	final Map<String, UserOrg> users = findAll();
	if (requiredGroups == null) {
		// No constraint on group
		addFilteredByCompaniesAndPattern(users.keySet(), companies, criteria, result, users);
	} else {
		// User must be within one the given groups
		for (final GroupOrg requiredGroup : requiredGroups) {
			addFilteredByCompaniesAndPattern(requiredGroup.getMembers(), companies, criteria, result, users);
		}
	}

	// Apply in-memory pagination
	return inMemoryPagination.newPage(result, pageable);
}
 
开发者ID:ligoj,项目名称:plugin-id-ldap,代码行数:29,代码来源:UserLdapRepository.java

示例15: opened

import org.apache.commons.collections4.IteratorUtils; //导入方法依赖的package包/类
/**
 * A new neighbors has been added, the link must be acknowledged before it is
 * used.
 * 
 * @param n
 *            The new neighbor.
 */
public void opened(Node n, Node mediator) {
	APeerSampling ps = (APeerSampling) this.node.getProtocol(FastConfig.getLinkable(PreventiveCausalBroadcast.pid));
	List<Node> neighborhood = IteratorUtils.toList(ps.getAliveNeighbors().iterator());
	if (neighborhood.size() - this.buffers.size() >= 1) {
		this.buffers.put(n, new ArrayList<MReliableBroadcast>());
		this._sendLocked(n, mediator);
	}
}
 
开发者ID:Chat-Wane,项目名称:peersim-pcbroadcast,代码行数:16,代码来源:PreventiveCausalBroadcast.java


注:本文中的org.apache.commons.collections4.IteratorUtils.toList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。