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


Java IteratorUtils类代码示例

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


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

示例1: init

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
/**
 * Putting this init here so that we can discover the file fields before running the actual rec
 */
public void init() {
    if (!this.initialized) {
        try {
            MutableList<String> fields;
            if (csvVersion == CsvStaticDataReader.CSV_V2) {
                CSVFormat csvFormat = getCsvFormat(delim, nullToken);
                this.csvreaderV2 = new CSVParser(reader, csvFormat);
                this.iteratorV2 = csvreaderV2.iterator();
                fields = ListAdapter.adapt(IteratorUtils.toList(iteratorV2.next().iterator()));
            } else {
                this.csvreaderV1 = new au.com.bytecode.opencsv.CSVReader(this.reader, this.delim);
                fields = ArrayAdapter.adapt(this.csvreaderV1.readNext());
            }

            this.fields = fields.collect(this.convertDbObjectName);
        } catch (Exception e) {
            throw new DeployerRuntimeException(e);
        }
        this.initialized = true;
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:25,代码来源:CsvReaderDataSource.java

示例2: testGetXmlConfigurationFromMap

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
/**
 * Tests getting a single object configuration via passing the path and the map of the desired values.
 *
 * @throws ConfigurationException if the testing xml file is not there.
 */
@Test
public void testGetXmlConfigurationFromMap() throws ConfigurationException {
    Map<String, String> pathAndValues = new HashMap<>();
    pathAndValues.put("capable-switch.id", "openvswitch");
    pathAndValues.put("switch.id", "ofc-bridge");
    pathAndValues.put("controller.id", "tcp:1.1.1.1:1");
    pathAndValues.put("controller.ip-address", "1.1.1.1");
    XMLConfiguration cfg = utils.getXmlConfiguration(OF_CONFIG_XML_PATH, pathAndValues);
    testCreateConfig.load(getClass().getResourceAsStream("/testCreateSingleYangConfig.xml"));
    assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig);

    assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                 IteratorUtils.toList(cfg.getKeys()));

    assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
                 utils.getString(cfg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:YangXmlUtilsTest.java

示例3: getXmlConfigurationFromYangElements

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
/**
 * Tests getting a multiple object nested configuration via passing the path
 * and a list of YangElements containing with the element and desired value.
 *
 * @throws ConfigurationException
 */
@Test
public void getXmlConfigurationFromYangElements() throws ConfigurationException {

    assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig);
    testCreateConfig.load(getClass().getResourceAsStream("/testYangConfig.xml"));
    List<YangElement> elements = new ArrayList<>();
    elements.add(new YangElement("capable-switch", ImmutableMap.of("id", "openvswitch")));
    elements.add(new YangElement("switch", ImmutableMap.of("id", "ofc-bridge")));
    List<ControllerInfo> controllers =
            ImmutableList.of(new ControllerInfo(IpAddress.valueOf("1.1.1.1"), 1, "tcp"),
                             new ControllerInfo(IpAddress.valueOf("2.2.2.2"), 2, "tcp"));
    controllers.stream().forEach(cInfo -> {
        elements.add(new YangElement("controller", ImmutableMap.of("id", cInfo.target(),
                                                                   "ip-address", cInfo.ip().toString())));
    });
    XMLConfiguration cfg =
            new XMLConfiguration(YangXmlUtils.getInstance()
                                         .getXmlConfiguration(OF_CONFIG_XML_PATH, elements));
    assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                 IteratorUtils.toList(cfg.getKeys()));
    assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
                 utils.getString(cfg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:YangXmlUtilsTest.java

示例4: parsePhysicalPlan

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void parsePhysicalPlan() throws IOException {
  if (queryProfile.getJsonPlan() == null || queryProfile.getJsonPlan().isEmpty()) {
    return;
  }
  // Parse the plan and map tables to major fragment and operator ids.
  final Map<String, Object> plan = mapper.readValue(queryProfile.getJsonPlan(), Map.class);
  for (Map.Entry<String, Object> entry: plan.entrySet()) {
    checkIsAssignable(entry.getKey(), entry.getValue().getClass(), Map.class);
    final Map<String, Object> operatorInfo = (Map)entry.getValue();
    final String operator = (String) operatorInfo.get("\"op\"");
    if (operator != null && operator.contains("Scan") && operatorInfo.containsKey("\"values\"")) {
      // Get table name
      checkIsAssignable(entry.getKey() + ": values", operatorInfo.get("\"values\"").getClass(), Map.class);
      final Map<String, Object> values = (Map)operatorInfo.get("\"values\"");
      if (values.containsKey("\"table\"")) {
        // TODO (Amit H) remove this after we clean up code.
        final String tokens = ((String) values.get("\"table\"")).replaceAll("^\\[|\\]$", "");
        final String tablePath = PathUtils.constructFullPath(IteratorUtils.toList(splitter.split(tokens).iterator()));
        operatorToTable.put(entry.getKey(), tablePath);
      }
    }
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:25,代码来源:QueryProfileParser.java

示例5: testRemovalOfCommentsProperSplittingOfStatementsAndTrimmingOfEachOfIt

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testRemovalOfCommentsProperSplittingOfStatementsAndTrimmingOfEachOfIt() {
    // GIVEN
    final SqlScript script = new SqlScript(TEST_SCRIPT);

    // WHEN
    final List<String> list = IteratorUtils.toList(script.iterator());

    // THEN
    assertThat(list.size(), equalTo(12));
    assertThat(list, everyItem(not(containsString("comment"))));
    assertThat(list, everyItem(not(startsWith(" "))));
    assertThat(list, everyItem(not(startsWith("\t"))));
    assertThat(list, everyItem(not(endsWith(" "))));
    assertThat(list, everyItem(not(endsWith("\t"))));
}
 
开发者ID:dadrus,项目名称:jpa-unit,代码行数:18,代码来源:SqlScriptTest.java

示例6: readAsString

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Override
public String readAsString(final Object object) {
    final StringBuilder sb = new StringBuilder();
    sb.append('[');
    final Converter<T> converter = resolveConverter();
    for (final Iterator<?> it = IteratorUtils.getIterator(object); it.hasNext();) {
        final Object value = it.next();
        final T baseValue = CoercionHelper.coerce(elementType, value);
        sb.append('"').append(converter.toString(baseValue)).append('"');
        if (it.hasNext()) {
            sb.append(',');
        }
    }
    sb.append(']');
    return sb.toString();
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:17,代码来源:SimpleCollectionBinder.java

示例7: writeAsString

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Override
public void writeAsString(final Object object, final Object value) {
    validateNestedBinders();
    final Map<String, String> values = new HashMap<String, String>();
    if (value instanceof Map<?, ?>) {
        for (final Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet()) {
            final String keyAsString = keyBinder.readAsString(Collections.singletonMap(keyBinder.getPath(), entry.getKey()));
            final String valueAsString = valueBinder.readAsString(Collections.singletonMap(valueBinder.getPath(), entry.getValue()));
            values.put(keyAsString, valueAsString);
        }
    } else {
        for (final Iterator<?> it = IteratorUtils.getIterator(value); it.hasNext();) {
            final Object current = it.next();
            values.put(keyBinder.readAsString(current), valueBinder.readAsString(current));
        }
    }
    doWrite(object, values);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:19,代码来源:MapBinder.java

示例8: coerceCollection

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
/**
    * Converts an object to a collection of the given type, using the given element type
    * @return The resulting collection - it may be empty, but never null
    */
   @SuppressWarnings({ "unchecked", "rawtypes" })
   public static <T> Collection<T> coerceCollection(final Class<T> elementType, final Class<? extends Collection> collectionType, final Object value) {
final ArrayList<T> al = new ArrayList<T>();
       //final Collection<T> collection = ClassHelper.instantiate(collectionType == null ? al.getClass() : collectionType);
Collection<T> collection;
if(collectionType == null) {
	collection = ClassHelper.instantiate(al.getClass());
} else {
	collection = ClassHelper.instantiate(collectionType);
}

       final Iterator<?> iterator = IteratorUtils.getIterator(value);
       while (iterator.hasNext()) {
           collection.add(coerce(elementType, iterator.next()));
       }
       return collection;
   }
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:22,代码来源:CoercionHelper.java

示例9: executeQuery

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<?> executeQuery(final ActionContext context) {
    final MembersReportHandler reportHandler = getReportHandler();
    final Pair<MembersTransactionsReportDTO, Iterator<MemberTransactionSummaryReportData>> pair = reportHandler.handleTransactionsSummary(context);
    final MembersTransactionsReportDTO dto = pair.getFirst();
    final Iterator<MemberTransactionSummaryReportData> reportIterator = pair.getSecond();
    final Iterator iterator = IteratorUtils.filteredIterator(reportIterator, new Predicate() {
        @Override
        public boolean evaluate(final Object element) {
            final MemberTransactionSummaryReportData data = (MemberTransactionSummaryReportData) element;
            if (dto.isIncludeNoTraders()) {
                return true;
            }
            return data.isHasData();
        }
    });
    return new IteratorListImpl(iterator);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:20,代码来源:ExportMembersTransactionsReportToCsvAction.java

示例10: executeQuery

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<?> executeQuery(final ActionContext context) {
    final MembersReportHandler reportHandler = getReportHandler();
    final Pair<MembersTransactionsReportDTO, Iterator<MemberTransactionDetailsReportData>> pair = reportHandler.handleTransactionsDetails(context);
    final MembersTransactionsReportDTO dto = pair.getFirst();
    final Iterator<MemberTransactionDetailsReportData> reportIterator = pair.getSecond();
    final Iterator iterator = IteratorUtils.filteredIterator(reportIterator, new Predicate() {
        @Override
        public boolean evaluate(final Object element) {
            final MemberTransactionDetailsReportData data = (MemberTransactionDetailsReportData) element;
            if (dto.isIncludeNoTraders()) {
                return true;
            }
            return data.getAmount() != null;
        }
    });
    return new IteratorListImpl(iterator);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:20,代码来源:ExportMembersTransactionsDetailsToCsvAction.java

示例11: removeSubnet

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Override
public void removeSubnet(final String providerSubnetId) throws CloudException, InternalException {
    List<DataCenter> dataCenters = new ArrayList(IteratorUtils.toList(this.provider.getDataCenterServices().listDataCenters(this.provider.getContext().getRegionId()).iterator()));
    String dataCenterId = dataCenters.get(0).getProviderDataCenterId();

    WAPSubnetsModel subnetsModel = new AzurePackRequester(provider, new AzurePackNetworkRequests(provider).listSubnets(dataCenterId).build()).withJsonProcessor(WAPSubnetsModel.class).execute();

    WAPSubnetModel foundSubnetModel = (WAPSubnetModel)CollectionUtils.find(subnetsModel.getSubnets(), new Predicate() {
        @Override
        public boolean evaluate(Object object) {
            return ((WAPSubnetModel) object).getId().equalsIgnoreCase(providerSubnetId);
        }
    });

    if(foundSubnetModel == null)
        throw new InternalException("Invalid subnet providerSubnetId provided");

    new AzurePackRequester(provider, new AzurePackNetworkRequests(provider).deleteSubnet(foundSubnetModel).build()).execute();
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:20,代码来源:AzurePackNetworkSupport.java

示例12: listAllProductsShouldReturnCorrectHardwareProfileProducts

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Test
public void listAllProductsShouldReturnCorrectHardwareProfileProducts() throws CloudException, InternalException {
    new ListProductsRequestExecutorMockUp();
    List<VirtualMachineProduct> products = IteratorUtils
            .toList(azurePackVirtualMachineSupport.listAllProducts().iterator());

    //listAllProducts returns all available hardware profile plus default product
    assertEquals("listProducts doesn't return correct result", 2, products.size());
    VirtualMachineProduct virtualMachineProduct = products.get(0);
    assertEquals("listProducts doesn't return correct result", HWP_1_NAME, virtualMachineProduct.getName());
    assertEquals("listProducts doesn't return correct result", HWP_1_ID, virtualMachineProduct.getProviderProductId());
    assertEquals("listProducts doesn't return correct result", Integer.parseInt(HWP_1_CPU_COUNT), virtualMachineProduct.getCpuCount());
    assertEquals("listProducts doesn't return correct result", Double.parseDouble(HWP_1_MEMORY), virtualMachineProduct.getRamSize().getQuantity());
    assertEquals("listProducts doesn't return correct result", Storage.MEGABYTE,
            virtualMachineProduct.getRamSize().getUnitOfMeasure());

    //assert default product
    virtualMachineProduct = products.get(1);
    assertEquals("listProducts doesn't return correct result", "default", virtualMachineProduct.getName().toLowerCase());
    assertEquals("listProducts doesn't return correct result", "default", virtualMachineProduct.getProviderProductId().toLowerCase());
    assertEquals("listProducts doesn't return correct result", "default", virtualMachineProduct.getDescription().toLowerCase());

}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:24,代码来源:AzurePackVirtualMachineSupportTest.java

示例13: searchImagesShouldReturnCorrectResult

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Test
public void searchImagesShouldReturnCorrectResult() throws CloudException, InternalException {
    new GetAllImagesRequestExecutorMockUp();
    List<MachineImage> images;
    images = IteratorUtils.toList(azurePackImageSupport.searchImages(null, null, null, null).iterator());
    assertEquals("searchImages doesn't return correct result", 6, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, null, null).iterator());
    assertEquals("searchImages doesn't return correct result", 2, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, Platform.WINDOWS, null).iterator());
    assertEquals("searchImages doesn't return correct result", 2, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, Platform.WINDOWS, null,
            ImageClass.MACHINE).iterator());
    assertEquals("searchImages doesn't return correct result", 2, images.size());

    images = IteratorUtils.toList(azurePackImageSupport.searchImages(ACCOUNT_NO, null, Platform.WINDOWS, null,
            ImageClass.KERNEL).iterator());
    assertEquals("searchImages doesn't return correct result", 0, images.size());
}
 
开发者ID:dasein-cloud,项目名称:dasein-cloud-azurepack,代码行数:22,代码来源:AzurePackImageSupportTest.java

示例14: toString

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
@Override
public String toString() {
	StringBuilder sb = new StringBuilder();
	sb.append("Graph {\n");
	Iterator<Integer> it = base.iterator();
	while (it.hasNext()) {
		Integer node = it.next();
		sb.append("\t" + get(node) + ": ");
		@SuppressWarnings("unchecked")
		List<String> neighbors = IndexUtil.map(IteratorUtils.toList(base.getNeighbors(node)), this);
		sb.append(StringUtils.join(neighbors, ','));
		sb.append("\n");
	}
	sb.append("}\n");
	return sb.toString();
}
 
开发者ID:procyon-lotor,项目名称:event-direct-mts,代码行数:17,代码来源:StringIndexGraphWrapper.java

示例15: convert

import org.apache.commons.collections.IteratorUtils; //导入依赖的package包/类
private Set<VolumeDto> convert(Iterable<BackupEntry> entries) {
    List<BackupEntry> backupList = IteratorUtils.toList(entries.iterator());
    Comparator<BackupEntry> cmp = Comparator.comparingLong(backup-> Long.parseLong(backup.getTimeCreated()));
    Collections.sort(backupList, cmp.reversed());
    Map<String, VolumeDto> dtos = new HashMap<>();

    for (BackupEntry entry : backupList) {
        VolumeDto dto = new VolumeDto();

        dto.setVolumeId(entry.getVolumeId());
        dto.setSize(0);

        dto.setInstanceID(EMPTY);
        dto.setVolumeName(entry.getVolumeName());
        dto.setTags(Collections.EMPTY_LIST);
        dto.setAvailabilityZone(EMPTY);
        dto.setSnapshotId(EMPTY);
        dto.setState(REMOVED_VOLUME_STATE);
        if(!dtos.containsKey(dto.getVolumeId())) {
            dtos.put(dto.getVolumeId(), dto);
        }
    }
    return new HashSet<>(dtos.values());
}
 
开发者ID:SungardAS,项目名称:enhanced-snapshots,代码行数:25,代码来源:VolumeServiceImpl.java


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