Search in sources :

Example 66 with Consumer

use of java.util.function.Consumer in project Gargoyle by callakrsos.

the class SVNLog method logFileSystem.

/********************************
	 * 작성일 : 2016. 7. 13. 작성자 : KYJ
	 *
	 *
	 * @param path
	 * @param startRevision
	 * @param endDate
	 * @param exceptionHandler
	 * @return
	 ********************************/
public List<SVNLogEntry> logFileSystem(File[] path, long startRevision, Date endDate, Consumer<Exception> exceptionHandler) {
    SVNLogClient logClient = getSvnManager().getLogClient();
    List<SVNLogEntry> result = new ArrayList<>();
    try {
        ISVNLogEntryHandler handler = logEntry -> {
            LOGGER.debug("path :: {}  rivision :: {} date :: {} author :: {} message :: {} ", path, logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());
            result.add(logEntry);
        };
        doLog(path, startRevision, endDate, logClient, handler);
    } catch (SVNException e) {
        LOGGER.error(ValueUtil.toString(e));
        if (exceptionHandler != null)
            exceptionHandler.accept(e);
    }
    return result;
}
Also used : ILogCommand(com.kyj.scm.manager.core.commons.ILogCommand) Properties(java.util.Properties) Logger(org.slf4j.Logger) URLDecoder(java.net.URLDecoder) SVNException(org.tmatesoft.svn.core.SVNException) Date(java.util.Date) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) File(java.io.File) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) List(java.util.List) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ArrayList(java.util.ArrayList) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient)

Example 67 with Consumer

use of java.util.function.Consumer in project Gargoyle by callakrsos.

the class SVNLog method log.

/********************************
	 * 작성일 : 2016. 5. 5. 작성자 : KYJ
	 *
	 * 이력정보 조회
	 *
	 * @param path
	 *            상대경로
	 * @param revision
	 *            리비젼번호
	 * @param exceptionHandler
	 *            에러발생시 처리할 핸들 정의
	 * @return
	 ********************************/
public List<SVNLogEntry> log(String path, String revision, Consumer<Exception> exceptionHandler) {
    SVNLogClient logClient = getSvnManager().getLogClient();
    List<SVNLogEntry> result = new ArrayList<>();
    try {
        ISVNLogEntryHandler handler = logEntry -> {
            LOGGER.debug("rivision :: {} date :: {} author :: {} message :: {} ", logEntry.getRevision(), logEntry.getDate(), logEntry.getAuthor(), logEntry.getMessage());
            result.add(logEntry);
        };
        String _path = path;
        try {
            _path = URLDecoder.decode(_path, "UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        logClient.doLog(getSvnURL(), new String[] { _path }, SVNRevision.create(Long.parseLong(revision)), SVNRevision.create(Long.parseLong(revision) == -1 ? 0 : Long.parseLong(revision)), SVNRevision.HEAD, true, false, 100L, handler);
    } catch (SVNException e) {
        if (exceptionHandler != null)
            exceptionHandler.accept(e);
        else
            LOGGER.error(ValueUtil.toString(e));
    }
    return result;
}
Also used : ILogCommand(com.kyj.scm.manager.core.commons.ILogCommand) Properties(java.util.Properties) Logger(org.slf4j.Logger) URLDecoder(java.net.URLDecoder) SVNException(org.tmatesoft.svn.core.SVNException) Date(java.util.Date) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) File(java.io.File) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) List(java.util.List) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ArrayList(java.util.ArrayList) ISVNLogEntryHandler(org.tmatesoft.svn.core.ISVNLogEntryHandler) SVNException(org.tmatesoft.svn.core.SVNException) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) SVNException(org.tmatesoft.svn.core.SVNException)

Example 68 with Consumer

use of java.util.function.Consumer in project jdk8u_jdk by JetBrains.

the class StreamSpliteratorTest method testDoubleSplitting.

//
public void testDoubleSplitting() {
    List<Consumer<DoubleStream>> terminalOps = Arrays.asList(s -> s.toArray(), s -> s.forEach(e -> {
    }), s -> s.reduce(Double::sum));
    List<UnaryOperator<DoubleStream>> intermediateOps = Arrays.asList(s -> s.parallel(), // The following ensures the wrapping spliterator is tested
    s -> s.map(i -> i).parallel());
    for (int i = 0; i < terminalOps.size(); i++) {
        Consumer<DoubleStream> terminalOp = terminalOps.get(i);
        setContext("termOpIndex", i);
        for (int j = 0; j < intermediateOps.size(); j++) {
            UnaryOperator<DoubleStream> intermediateOp = intermediateOps.get(j);
            setContext("intOpIndex", j);
            for (boolean proxyEstimateSize : new boolean[] { false, true }) {
                setContext("proxyEstimateSize", proxyEstimateSize);
                // Size is assumed to be larger than the target size for no splitting
                // @@@ Need way to obtain the target size
                Spliterator.OfDouble sp = intermediateOp.apply(IntStream.range(0, 1000).asDoubleStream()).spliterator();
                ProxyNoExactSizeSpliterator.OfDouble psp = new ProxyNoExactSizeSpliterator.OfDouble(sp, proxyEstimateSize);
                DoubleStream s = StreamSupport.doubleStream(psp, true);
                terminalOp.accept(s);
                Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.prefixSplits > 0, String.format("Number of non-null prefix splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.sizeOnTraversal < 1000, String.format("Size on traversal of last split should be less than the size of the list, %d, when proxyEstimateSize is %s", 1000, proxyEstimateSize));
            }
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) SpliteratorTestHelper(java.util.stream.SpliteratorTestHelper) IntConsumer(java.util.function.IntConsumer) UnaryOperator(java.util.function.UnaryOperator) Test(org.testng.annotations.Test) DoubleConsumer(java.util.function.DoubleConsumer) Function(java.util.function.Function) Assert(org.testng.Assert) LambdaTestHelpers.dpEven(java.util.stream.LambdaTestHelpers.dpEven) LambdaTestHelpers.irDoubler(java.util.stream.LambdaTestHelpers.irDoubler) StreamSupport(java.util.stream.StreamSupport) IntStreamTestDataProvider(java.util.stream.IntStreamTestDataProvider) LambdaTestHelpers.countTo(java.util.stream.LambdaTestHelpers.countTo) LongStream(java.util.stream.LongStream) LambdaTestHelpers.lpEven(java.util.stream.LambdaTestHelpers.lpEven) DoubleStreamTestDataProvider(java.util.stream.DoubleStreamTestDataProvider) TestData(java.util.stream.TestData) StreamTestDataProvider(java.util.stream.StreamTestDataProvider) LambdaTestHelpers.permuteStreamFunctions(java.util.stream.LambdaTestHelpers.permuteStreamFunctions) LongConsumer(java.util.function.LongConsumer) DoubleStream(java.util.stream.DoubleStream) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) LambdaTestHelpers(java.util.stream.LambdaTestHelpers) OpTestCase(java.util.stream.OpTestCase) LambdaTestHelpers.mDoubler(java.util.stream.LambdaTestHelpers.mDoubler) LongStreamTestDataProvider(java.util.stream.LongStreamTestDataProvider) LambdaTestHelpers.pEven(java.util.stream.LambdaTestHelpers.pEven) LambdaTestHelpers.ipEven(java.util.stream.LambdaTestHelpers.ipEven) Comparator(java.util.Comparator) Spliterator(java.util.Spliterator) IntConsumer(java.util.function.IntConsumer) DoubleConsumer(java.util.function.DoubleConsumer) LongConsumer(java.util.function.LongConsumer) Consumer(java.util.function.Consumer) DoubleStream(java.util.stream.DoubleStream) UnaryOperator(java.util.function.UnaryOperator) Spliterator(java.util.Spliterator)

Example 69 with Consumer

use of java.util.function.Consumer in project jdk8u_jdk by JetBrains.

the class StreamSpliteratorTest method testIntSplitting.

//
public void testIntSplitting() {
    List<Consumer<IntStream>> terminalOps = Arrays.asList(s -> s.toArray(), s -> s.forEach(e -> {
    }), s -> s.reduce(Integer::sum));
    List<UnaryOperator<IntStream>> intermediateOps = Arrays.asList(s -> s.parallel(), // The following ensures the wrapping spliterator is tested
    s -> s.map(i -> i).parallel());
    for (int i = 0; i < terminalOps.size(); i++) {
        setContext("termOpIndex", i);
        Consumer<IntStream> terminalOp = terminalOps.get(i);
        for (int j = 0; j < intermediateOps.size(); j++) {
            setContext("intOpIndex", j);
            UnaryOperator<IntStream> intermediateOp = intermediateOps.get(j);
            for (boolean proxyEstimateSize : new boolean[] { false, true }) {
                setContext("proxyEstimateSize", proxyEstimateSize);
                // Size is assumed to be larger than the target size for no splitting
                // @@@ Need way to obtain the target size
                Spliterator.OfInt sp = intermediateOp.apply(IntStream.range(0, 1000)).spliterator();
                ProxyNoExactSizeSpliterator.OfInt psp = new ProxyNoExactSizeSpliterator.OfInt(sp, proxyEstimateSize);
                IntStream s = StreamSupport.intStream(psp, true);
                terminalOp.accept(s);
                Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.prefixSplits > 0, String.format("Number of non-null prefix splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.sizeOnTraversal < 1000, String.format("Size on traversal of last split should be less than the size of the list, %d, when proxyEstimateSize is %s", 1000, proxyEstimateSize));
            }
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) SpliteratorTestHelper(java.util.stream.SpliteratorTestHelper) IntConsumer(java.util.function.IntConsumer) UnaryOperator(java.util.function.UnaryOperator) Test(org.testng.annotations.Test) DoubleConsumer(java.util.function.DoubleConsumer) Function(java.util.function.Function) Assert(org.testng.Assert) LambdaTestHelpers.dpEven(java.util.stream.LambdaTestHelpers.dpEven) LambdaTestHelpers.irDoubler(java.util.stream.LambdaTestHelpers.irDoubler) StreamSupport(java.util.stream.StreamSupport) IntStreamTestDataProvider(java.util.stream.IntStreamTestDataProvider) LambdaTestHelpers.countTo(java.util.stream.LambdaTestHelpers.countTo) LongStream(java.util.stream.LongStream) LambdaTestHelpers.lpEven(java.util.stream.LambdaTestHelpers.lpEven) DoubleStreamTestDataProvider(java.util.stream.DoubleStreamTestDataProvider) TestData(java.util.stream.TestData) StreamTestDataProvider(java.util.stream.StreamTestDataProvider) LambdaTestHelpers.permuteStreamFunctions(java.util.stream.LambdaTestHelpers.permuteStreamFunctions) LongConsumer(java.util.function.LongConsumer) DoubleStream(java.util.stream.DoubleStream) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) LambdaTestHelpers(java.util.stream.LambdaTestHelpers) OpTestCase(java.util.stream.OpTestCase) LambdaTestHelpers.mDoubler(java.util.stream.LambdaTestHelpers.mDoubler) LongStreamTestDataProvider(java.util.stream.LongStreamTestDataProvider) LambdaTestHelpers.pEven(java.util.stream.LambdaTestHelpers.pEven) LambdaTestHelpers.ipEven(java.util.stream.LambdaTestHelpers.ipEven) Comparator(java.util.Comparator) Spliterator(java.util.Spliterator) IntConsumer(java.util.function.IntConsumer) DoubleConsumer(java.util.function.DoubleConsumer) LongConsumer(java.util.function.LongConsumer) Consumer(java.util.function.Consumer) UnaryOperator(java.util.function.UnaryOperator) IntStream(java.util.stream.IntStream) Spliterator(java.util.Spliterator)

Example 70 with Consumer

use of java.util.function.Consumer in project jdk8u_jdk by JetBrains.

the class StreamSpliteratorTest method testLongSplitting.

//
public void testLongSplitting() {
    List<Consumer<LongStream>> terminalOps = Arrays.asList(s -> s.toArray(), s -> s.forEach(e -> {
    }), s -> s.reduce(Long::sum));
    List<UnaryOperator<LongStream>> intermediateOps = Arrays.asList(s -> s.parallel(), // The following ensures the wrapping spliterator is tested
    s -> s.map(i -> i).parallel());
    for (int i = 0; i < terminalOps.size(); i++) {
        Consumer<LongStream> terminalOp = terminalOps.get(i);
        setContext("termOpIndex", i);
        for (int j = 0; j < intermediateOps.size(); j++) {
            setContext("intOpIndex", j);
            UnaryOperator<LongStream> intermediateOp = intermediateOps.get(j);
            for (boolean proxyEstimateSize : new boolean[] { false, true }) {
                setContext("proxyEstimateSize", proxyEstimateSize);
                // Size is assumed to be larger than the target size for no splitting
                // @@@ Need way to obtain the target size
                Spliterator.OfLong sp = intermediateOp.apply(LongStream.range(0, 1000)).spliterator();
                ProxyNoExactSizeSpliterator.OfLong psp = new ProxyNoExactSizeSpliterator.OfLong(sp, proxyEstimateSize);
                LongStream s = StreamSupport.longStream(psp, true);
                terminalOp.accept(s);
                Assert.assertTrue(psp.splits > 0, String.format("Number of splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.prefixSplits > 0, String.format("Number of non-null prefix splits should be greater that zero when proxyEstimateSize is %s", proxyEstimateSize));
                Assert.assertTrue(psp.sizeOnTraversal < 1000, String.format("Size on traversal of last split should be less than the size of the list, %d, when proxyEstimateSize is %s", 1000, proxyEstimateSize));
            }
        }
    }
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) SpliteratorTestHelper(java.util.stream.SpliteratorTestHelper) IntConsumer(java.util.function.IntConsumer) UnaryOperator(java.util.function.UnaryOperator) Test(org.testng.annotations.Test) DoubleConsumer(java.util.function.DoubleConsumer) Function(java.util.function.Function) Assert(org.testng.Assert) LambdaTestHelpers.dpEven(java.util.stream.LambdaTestHelpers.dpEven) LambdaTestHelpers.irDoubler(java.util.stream.LambdaTestHelpers.irDoubler) StreamSupport(java.util.stream.StreamSupport) IntStreamTestDataProvider(java.util.stream.IntStreamTestDataProvider) LambdaTestHelpers.countTo(java.util.stream.LambdaTestHelpers.countTo) LongStream(java.util.stream.LongStream) LambdaTestHelpers.lpEven(java.util.stream.LambdaTestHelpers.lpEven) DoubleStreamTestDataProvider(java.util.stream.DoubleStreamTestDataProvider) TestData(java.util.stream.TestData) StreamTestDataProvider(java.util.stream.StreamTestDataProvider) LambdaTestHelpers.permuteStreamFunctions(java.util.stream.LambdaTestHelpers.permuteStreamFunctions) LongConsumer(java.util.function.LongConsumer) DoubleStream(java.util.stream.DoubleStream) Consumer(java.util.function.Consumer) List(java.util.List) Stream(java.util.stream.Stream) LambdaTestHelpers(java.util.stream.LambdaTestHelpers) OpTestCase(java.util.stream.OpTestCase) LambdaTestHelpers.mDoubler(java.util.stream.LambdaTestHelpers.mDoubler) LongStreamTestDataProvider(java.util.stream.LongStreamTestDataProvider) LambdaTestHelpers.pEven(java.util.stream.LambdaTestHelpers.pEven) LambdaTestHelpers.ipEven(java.util.stream.LambdaTestHelpers.ipEven) Comparator(java.util.Comparator) Spliterator(java.util.Spliterator) LongStream(java.util.stream.LongStream) IntConsumer(java.util.function.IntConsumer) DoubleConsumer(java.util.function.DoubleConsumer) LongConsumer(java.util.function.LongConsumer) Consumer(java.util.function.Consumer) UnaryOperator(java.util.function.UnaryOperator) Spliterator(java.util.Spliterator)

Aggregations

Consumer (java.util.function.Consumer)908 List (java.util.List)445 ArrayList (java.util.ArrayList)288 Test (org.junit.Test)250 Map (java.util.Map)228 IOException (java.io.IOException)223 Collectors (java.util.stream.Collectors)205 Collections (java.util.Collections)185 Arrays (java.util.Arrays)181 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)163 TimeUnit (java.util.concurrent.TimeUnit)157 HashMap (java.util.HashMap)152 Set (java.util.Set)149 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)146 Optional (java.util.Optional)132 Collection (java.util.Collection)127 Function (java.util.function.Function)119 CountDownLatch (java.util.concurrent.CountDownLatch)116 File (java.io.File)112 AtomicReference (java.util.concurrent.atomic.AtomicReference)111