org.eclipse.collections.impl.block.factory.HashingStrategies Java Examples

The following examples show how to use org.eclipse.collections.impl.block.factory.HashingStrategies. 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
Source File: MithraObjectGraphExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private Map<Pair<RelatedFinder, Object>, List<MithraDataObject>> extractData(ExecutorService executor)
{
    ExtractResult result = new ExtractResult();
    for (Operation operation : operations)
    {
        RelatedFinder finder = operation.getResultObjectPortal().getFinder();
        MithraList mithraList = finder.findMany(this.milestoneStrategy.addAsOfOperations(operation));
        if (mithraList.notEmpty())
        {
            FullUniqueIndex pkIndex = createDatelessIndex(mithraList);
            ExtractResult operationResult = new ExtractResult();
            UnifiedSetWithHashingStrategy<RelatedFinder> toManyRelationships = UnifiedSetWithHashingStrategy.newSet(HashingStrategies.identityStrategy());
            this.traverserQueue.add(new RelationshipTraverser(mithraList, pkIndex, operationResult, toManyRelationships, executor, finder.getMithraObjectPortal().getBusinessClassName()));
            while (!this.traverserQueue.isEmpty())
            {
                this.traverserQueue.poll().traverse();
            }
            result.merge(operationResult);
        }
    }
    return result.getDataObjectsByFinderAndSource();
}
 
Example #2
Source File: Main.java    From obevo with Apache License 2.0 5 votes vote down vote up
protected Main() {
    // use the hashing strategy to allow commands of any case to be handled
    MutableMap<String, Procedure<String[]>> commandMap = HashingStrategyMaps.mutable.of(HashingStrategies.fromFunction(new Function<String, String>() {
        @Override
        public String valueOf(String s) {
            return s.toLowerCase();
        }
    }));
    commandMap.putAll(getCommandMap().toMap());
    this.commandMap = commandMap.toImmutable();
}
 
Example #3
Source File: PlatformConfigReader.java    From obevo with Apache License 2.0 5 votes vote down vote up
private MutableList<PropertyInput> readConfigPackages(RichIterable<String> configPackages) {
    MutableSet<PropertyInput> prioritizedProperties = HashingStrategySets.mutable.of(HashingStrategies.fromFunction(new Function<PropertyInput, URL>() {
        @Override
        public URL valueOf(PropertyInput propertyInput) {
            return propertyInput.getPropertyFilePath();
        }
    }));

    for (String configPackage : configPackages) {
        ListIterable<FileObject> fileObjects = FileRetrievalMode.CLASSPATH.resolveFileObjects(configPackage)
                .flatCollect(new Function<FileObject, Iterable<FileObject>>() {
                    @Override
                    public Iterable<FileObject> valueOf(FileObject object) {
                        return ArrayAdapter.adapt(object.getChildren());
                    }
                });
        ListIterable<FileObject> propertyFiles = fileObjects
                .select(new Predicate<FileObject>() {
                    @Override
                    public boolean accept(FileObject it) {
                        return it.getName().getExtension().equals("yaml");
                    }
                });

        for (FileObject propertyFile : propertyFiles) {
            HierarchicalConfiguration<ImmutableNode> fileProps = loadPropertiesFromUrl(propertyFile);

            String configPriorityProp = fileProps.getString(PROP_CONFIG_PRIORITY);
            if (configPriorityProp != null) {
                int priority = Integer.parseInt(configPriorityProp);
                prioritizedProperties.add(new PropertyInput(propertyFile.getName().getBaseName(), propertyFile.getURLDa(), priority, fileProps));
            } else {
                LOG.warn("Property file {} was ignored as it did not contain {} property", propertyFile, PROP_CONFIG_PRIORITY);
            }
        }
    }
    return prioritizedProperties.toList();
}
 
Example #4
Source File: DistinctWithEclipseCollectionsUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void whenFilterListByName_thenSizeShouldBe4() {
    List<Person> personListFiltered = ListIterate.distinct(personList, HashingStrategies.fromFunction(Person::getName));
    assertTrue(personListFiltered.size() == 4);
}
 
Example #5
Source File: DistinctWithEclipseCollectionsUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Test
public void whenFilterListByAge_thenSizeShouldBe2() {
    List<Person> personListFiltered = ListIterate.distinct(personList, HashingStrategies.fromIntFunction(Person::getAge));
    assertTrue(personListFiltered.size() == 2);
}