Source:
<code>public void addBuildTrigger(IBuildTrigger trigger) { ModelNode triggers = get(BUILDCONFIG_TRIGGERS); ModelNode triggerNode = triggers.add(); switch(trigger.getType()) { case BuildTriggerType.generic: case BuildTriggerType.GENERIC: if(!(trigger instanceof IWebhookTrigger)) { throw new IllegalArgumentException("IBuildTrigger of type generic does not implement IWebhookTrigger"); } IWebhookTrigger generic = (IWebhookTrigger)trigger; triggerNode.get(getPath(BUILD_CONFIG_WEBHOOK_GENERIC_SECRET)).set(generic.getSecret()); break; case BuildTriggerType.github: case BuildTriggerType.GITHUB: if(!(trigger instanceof IWebhookTrigger)) { throw new IllegalArgumentException("IBuildTrigger of type github does not implement IWebhookTrigger"); } IWebhookTrigger github = (IWebhookTrigger)trigger; triggerNode.get(getPath(BUILD_CONFIG_WEBHOOK_GITHUB_SECRET)).set(github.getSecret()); break; case BuildTriggerType.imageChange: case BuildTriggerType.IMAGE_CHANGE:{ if(!(trigger instanceof IImageChangeTrigger)) { throw new IllegalArgumentException("IBuildTrigger of type imageChange does not implement IImageChangeTrigger"); } IImageChangeTrigger image = (IImageChangeTrigger)trigger; if(image.getImage() != null) <START> triggerNode.get(getPath(BUILD_CONFIG_IMAGECHANGE_IMAGE)).set(defaultIfNull(image.getImage())); <END> if(image.getFrom() != null) triggerNode.get(getPath(BUILD_CONFIG_IMAGECHANGE_NAME)).set(defaultIfNull(image.getFrom())); if(StringUtils.isNotEmpty(image.getTag())) triggerNode.get(getPath(BUILD_CONFIG_IMAGECHANGE_TAG)).set(StringUtils.defaultIfBlank(image.getTag(), "")); break; } } triggerNode.get(TYPE).set(trigger.getType()); }</code><technical_language>nitpicking here: need defaulIfNull null check is done :-) for next lines of code</technical_language>

Target:
public void addBuildTrigger(IBuildTrigger trigger) { ModelNode triggers = get(BUILDCONFIG_TRIGGERS); ModelNode triggerNode = triggers.add(); switch(trigger.getType()) { case BuildTriggerType.generic: case BuildTriggerType.GENERIC: if(!(trigger instanceof IWebhookTrigger)) { throw new IllegalArgumentException("IBuildTrigger of type generic does not implement IWebhookTrigger"); } IWebhookTrigger generic = (IWebhookTrigger)trigger; triggerNode.get(getPath(BUILD_CONFIG_WEBHOOK_GENERIC_SECRET)).set(generic.getSecret()); break; case BuildTriggerType.github: case BuildTriggerType.GITHUB: if(!(trigger instanceof IWebhookTrigger)) { throw new IllegalArgumentException("IBuildTrigger of type github does not implement IWebhookTrigger"); } IWebhookTrigger github = (IWebhookTrigger)trigger; triggerNode.get(getPath(BUILD_CONFIG_WEBHOOK_GITHUB_SECRET)).set(github.getSecret()); break; case BuildTriggerType.imageChange: case BuildTriggerType.IMAGE_CHANGE:{ if(!(trigger instanceof IImageChangeTrigger)) { throw new IllegalArgumentException("IBuildTrigger of type imageChange does not implement IImageChangeTrigger"); } IImageChangeTrigger image = (IImageChangeTrigger)trigger; if(image.getImage() != null) triggerNode.get(getPath(BUILD_CONFIG_IMAGECHANGE_IMAGE)).set(image.getImage().toString()); if(image.getFrom() != null) triggerNode.get(getPath(BUILD_CONFIG_IMAGECHANGE_NAME)).set(image.getFrom().toString()); if(StringUtils.isNotEmpty(image.getTag())) triggerNode.get(getPath(BUILD_CONFIG_IMAGECHANGE_TAG)).set(StringUtils.defaultIfBlank(image.getTag(), "")); break; } } triggerNode.get(TYPE).set(trigger.getType()); }