You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@twill.apache.org by "Alvin Wang (JIRA)" <ji...@apache.org> on 2014/03/14 21:58:42 UTC

[jira] [Commented] (TWILL-54) Add a better way to programmatically build a TwillSpecification

    [ https://issues.apache.org/jira/browse/TWILL-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13935629#comment-13935629 ] 

Alvin Wang commented on TWILL-54:
---------------------------------

Review created: https://reviews.apache.org/r/19236/

> Add a better way to programmatically build a TwillSpecification
> ---------------------------------------------------------------
>
>                 Key: TWILL-54
>                 URL: https://issues.apache.org/jira/browse/TWILL-54
>             Project: Apache Twill
>          Issue Type: Improvement
>          Components: api
>            Reporter: Andreas Neumann
>            Assignee: Alvin Wang
>
> I am writing a framework that builds a Twill app from a specification. While the builder pattern is convenient and foolproof for verbose construction of the  app spec, it is cumbersome to use programmatically:
>           TwillSpecification.Builder.MoreRunnable builder =
>             TwillSpecification.Builder.with().setName(className).withRunnable();
>           // iterate over my spec and add runnables
>           TwillSpecification.Builder.RunnableSetter setter = null;
>           for (...) { 
>             ResourceSpecification resources = ...
>             String name = ...
>             TwillRunnable runnable = ...
>             setter = setter == null ?
>               builder.add(name, runnable, resources).noLocalFiles() :
>               builder.add(name, runnable, resources).noLocalFiles();             }
>           }
>           // iterate over my spec and configure the order of runnables
>           TwillSpecification.Builder.NextOrder nextOrder = null;
>           for (...) {
>             String runnableName = ... // my logic
>             String[] runnableNames = ... // my logic
>             nextOrder = nextOrder == null ?
>               setter.withOrder().begin(runnableName, runnableNames) :
>               nextOrder.nextWhenCompleted(runnableName, runnableNames);
>           }
>           return nextOrder == null ? setter.anyOrder().build() : nextOrder.build();
> If would be easier if I did not have to use the builder pattern...



--
This message was sent by Atlassian JIRA
(v6.2#6252)