Package groovy.lang

Examples of groovy.lang.Closure$WritableClosure


        Object action = actualArgs.get(Task.TASK_ACTION);
        if (action instanceof Action) {
            Action<? super Task> taskAction = (Action<? super Task>) action;
            task.doFirst(taskAction);
        } else if (action != null) {
            Closure closure = (Closure) action;
            task.doFirst(closure);
        }

        return task;
    }
View Full Code Here


        for (Map.Entry<RelativePath, Closure> entry : elements.entrySet()) {
            if (stopFlag.get()) {
                break;
            }
            RelativePath path = entry.getKey();
            Closure generator = entry.getValue();
            visit.visit(path, generator);
        }
        return this;
    }
View Full Code Here

        while (!queue.isEmpty()) {
            Object first = queue.removeFirst();
            if (first instanceof FileCollection) {
                result.add(first);
            } else if (first instanceof Closure) {
                Closure closure = (Closure) first;
                Object closureResult = closure.call();
                if (closureResult != null) {
                    queue.addFirst(closureResult);
                }
            } else if (first instanceof Collection) {
                Collection<?> collection = (Collection<?>) first;
View Full Code Here

        assertSetContainsForAllTypes(tree, emptyList);
    }
   
    @Test
    public void canAddAnElementUsingAClosureToGeneratedContent() {
        Closure closure = HelperUtil.toClosure("{it.write('content'.getBytes())}");
        tree.add("path/file.txt", closure);

        assertVisits(tree, toList("path/file.txt"), toList("path"));
        assertSetContainsForAllTypes(tree, toList("path/file.txt"));
View Full Code Here

        rootDir.file("path/file.txt").assertContents(equalTo("content"));
    }

    @Test
    public void canAddMultipleElementsInDifferentDirs() {
        Closure closure = HelperUtil.toClosure("{it.write('content'.getBytes())}");
        tree.add("path/file.txt", closure);
        tree.add("file.txt", closure);
        tree.add("path/subdir/file.txt", closure);

        assertVisits(tree, toList("path/file.txt", "file.txt", "path/subdir/file.txt"), toList("path", "path/subdir"));
View Full Code Here

        assertSetContainsForAllTypes(tree, toList("path/file.txt", "file.txt", "path/subdir/file.txt"));
    }

    @Test
    public void canStopVisitingElements() {
        Closure closure = HelperUtil.toClosure("{it.write('content'.getBytes())}");
        tree.add("path/file.txt", closure);
        tree.add("file.txt", closure);
        assertCanStopVisiting(tree);
    }
View Full Code Here

            allowing(resolverMock).resolve('b');
            will(returnValue(file2));
        }});

        List<Character> files = toList('a');
        Closure closure = HelperUtil.returns(files);
        collection.from(closure);

        assertThat(collection.getFiles(), equalTo(toLinkedSet(file1)));

        files.add('b');
View Full Code Here

        assertThat(collection.getFiles(), equalTo(toLinkedSet(file1, file2)));
    }

    @Test
    public void canUseAClosureToSpecifyASingleFile() {
        Closure closure = HelperUtil.returns('a');
        final File file = new File("1");

        collection.from(closure);

        context.checking(new Expectations() {{
View Full Code Here

        assertThat(collection.getFiles(), equalTo(toLinkedSet(file)));
    }

    @Test
    public void closureCanReturnNull() {
        Closure closure = HelperUtil.returns(null);

        collection.from(closure);

        assertThat(collection.getFiles(), isEmpty());
    }
View Full Code Here

        }
    };

    @Test
    public void matchingWithClosureReturnsUnionOfFilteredSets() {
        final Closure closure = HelperUtil.TEST_CLOSURE;
        final FileTree filtered1 = context.mock(FileTree.class, "filtered1");
        final FileTree filtered2 = context.mock(FileTree.class, "filtered2");

        context.checking(new Expectations() {{
            one(source1).matching(closure);
View Full Code Here

TOP

Related Classes of groovy.lang.Closure$WritableClosure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.