Java Code Examples for org.eclipse.collections.api.list.MutableList#partition()

The following examples show how to use org.eclipse.collections.api.list.MutableList#partition() . 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: IqLoadFileCreator.java    From obevo with Apache License 2.0 6 votes vote down vote up
IqLoadFileCreator(String tableName, MutableList<FieldToColumnMapping> fieldToColumnMappings, File iqLoadDir,
        String loadFilePrefix, IqLoadMode iqLoadMode, DataExtractor dataExtractor) {
    this.tableName = tableName;

    PartitionMutableList<FieldToColumnMapping> parsedMappings =
            fieldToColumnMappings.partition(Predicates.attributeIsNull(FieldToColumnMapping.defaultValue()));

    this.mappingsWithoutDefaults = parsedMappings.getSelected();
    this.mappingsWithDefaults = parsedMappings.getRejected();
    this.iqLoadDir = iqLoadDir;
    this.loadFilePrefix = loadFilePrefix;
    this.cub.register(new SybaseIqLoadFieldConverter(), String.class);
    this.iqLoadMode = iqLoadMode;
    this.dataExtractor = dataExtractor;
    this.fileToWrite = new File(this.getFilePath());
    this.filePathToLoad =
            iqLoadMode.isConvertToWindowsFileSyntax() ? this.getFilePath().replace("\\", "\\\\") : this.getFilePath()
                    .replace("\\", "/");
}
 
Example 2
Source File: PartitionPatternUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void whenAnySatisfiesCondition_thenCorrect() {
    MutableList<Integer> numbers = list;
    PartitionMutableList<Integer> partitionedFolks = numbers.partition(new Predicate<Integer>() {

        /**
         * 
         */
        private static final long serialVersionUID = -1551138743683678406L;

        public boolean accept(Integer each) {
            return each > 30;
        }
    });
    MutableList<Integer> greaterThanThirty = partitionedFolks.getSelected().sortThis();
    MutableList<Integer> smallerThanThirty = partitionedFolks.getRejected().sortThis();

    Assertions.assertThat(smallerThanThirty).containsExactly(1, 5, 8, 17, 23);
    Assertions.assertThat(greaterThanThirty).containsExactly(31, 38, 41);
}