You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@whirr.apache.org by "Lars George (JIRA)" <ji...@apache.org> on 2011/01/25 13:50:43 UTC

[jira] Updated: (WHIRR-215) Add builder pattern to addRunUrl() call

     [ https://issues.apache.org/jira/browse/WHIRR-215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lars George updated WHIRR-215:
------------------------------

    Description: 
If we get optional parameters then the code using varargs gets messy:

{code}
String tarurl = clusterSpec.getConfiguration().getString(
  HBaseConstants.KEY_TARBALL_URL);
if (tarurl != null) {
  addRunUrl(event, hbaseInstallRunUrl,
    HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
    HBaseConstants.PARAM_TARBALL_URL, tarurl);
} else {
  addRunUrl(event, hbaseInstallRunUrl,
    HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
}
{code}

We should extend or add a builder pattern so that one can do something like

{code}
RunUrl ru = RunUrl.create(event)
  .url(hbaseInstallRunUrl)
  .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
if (tarUrl != null) {
  st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
}
addRunUrl(ru);
{code}

Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

  was:
If we get optional parameters then the code using varargs gets messy:

{code}
    String tarurl = clusterSpec.getConfiguration().getString(
      HBaseConstants.KEY_TARBALL_URL);
    if (tarurl != null) {
      addRunUrl(event, hbaseInstallRunUrl,
        HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
        HBaseConstants.PARAM_TARBALL_URL, tarurl);
    } else {
      addRunUrl(event, hbaseInstallRunUrl,
        HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
    }
{code}

We should extend or add a builder pattern so that one can do something like

{code}
  RunUrl ru = RunUrl.create(event)
    .url(hbaseInstallRunUrl)
    .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
  if (tarUrl != null) {
    st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
  }
  addRunUrl(ru);
{code}

Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.


> Add builder pattern to addRunUrl() call
> ---------------------------------------
>
>                 Key: WHIRR-215
>                 URL: https://issues.apache.org/jira/browse/WHIRR-215
>             Project: Whirr
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 0.3.0
>            Reporter: Lars George
>            Priority: Minor
>             Fix For: 0.4.0
>
>
> If we get optional parameters then the code using varargs gets messy:
> {code}
> String tarurl = clusterSpec.getConfiguration().getString(
>   HBaseConstants.KEY_TARBALL_URL);
> if (tarurl != null) {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider(),
>     HBaseConstants.PARAM_TARBALL_URL, tarurl);
> } else {
>   addRunUrl(event, hbaseInstallRunUrl,
>     HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> }
> {code}
> We should extend or add a builder pattern so that one can do something like
> {code}
> RunUrl ru = RunUrl.create(event)
>   .url(hbaseInstallRunUrl)
>   .arg(HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
> if (tarUrl != null) {
>   st.addArg(HBaseConstants.PARAM_TARBALL_URL, tarurl);
> }
> addRunUrl(ru);
> {code}
> Or similar to http://stackoverflow.com/questions/3838053/mapmaker-design-pattern referring to the Guava MapMaker class.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.