Source:
<code>public static PowerManagement map(VDS entity, PowerManagement template) { PowerManagement model = template != null ? template : new PowerManagement(); model.setType(entity.getPmType()); model.setEnabled(entity.getpm_enabled()); model.setAddress(entity.getManagementIp()); model.setUsername(entity.getPmUser()); if (entity.getPmOptionsMap() != null) { model.setOptions(map(entity.getPmOptionsMap(), null)); } if (entity.getPmProxyPreferences() != null) { PmProxies pmProxies = new PmProxies(); String[] proxies = StringUtils.split(entity.getPmProxyPreferences(), ","); for (String proxy : proxies) { PmProxy pmProxy = new PmProxy(); pmProxy.setType(proxy); pmProxies.getPmProxy().add(pmProxy); } model.setPmProxies(pmProxies); } if (entity.getpm_enabled()) { Agent agent = new Agent(); if (!StringUtils.isEmpty(entity.getManagementIp())) { agent.setType(entity.getPmType()); agent.setAddress(entity.getManagementIp()); agent.setUsername(entity.getPmUser()); if (entity.getPmOptionsMap() != null) { agent.setOptions(map(entity.getPmOptionsMap(), null)); } agent.setOrder(1); model.setAgents(new Agents()); model.getAgents().getAgents().add(agent); } if (!StringUtils.isEmpty(entity.getPmSecondaryIp())) { boolean concurrent = entity.isPmSecondaryConcurrent(); <START> model.getAgents().getAgents().get(0).setConcurrent(concurrent); <END> agent = new Agent(); agent.setType(entity.getPmSecondaryType()); agent.setAddress(entity.getPmSecondaryIp()); agent.setUsername(entity.getPmSecondaryUser()); if (entity.getPmOptionsMap() != null) { agent.setOptions(map(entity.getPmSecondaryOptionsMap(), null)); } agent.setOrder(2); agent.setConcurrent(concurrent); model.getAgents().getAgents().add(agent); } } return model; }</code><technical_language>I agree "rule" sense in future, is I suggest put in a place is a bit easier remove</technical_language>

Target:
public static PowerManagement map(VDS entity, PowerManagement template) { PowerManagement model = template != null ? template : new PowerManagement(); model.setType(entity.getPmType()); model.setEnabled(entity.getpm_enabled()); model.setAddress(entity.getManagementIp()); model.setUsername(entity.getPmUser()); model.setAutomaticPmEnabled(!entity.isDisablePowerManagementPolicy()); if (entity.getPmOptionsMap() != null) { model.setOptions(map(entity.getPmOptionsMap(), null)); } if (entity.getPmProxyPreferences() != null) { PmProxies pmProxies = new PmProxies(); String[] proxies = StringUtils.split(entity.getPmProxyPreferences(), ","); for (String proxy : proxies) { PmProxy pmProxy = new PmProxy(); pmProxy.setType(proxy); pmProxies.getPmProxy().add(pmProxy); } model.setPmProxies(pmProxies); } if (entity.getpm_enabled()) { Agent agent = new Agent(); if (!StringUtils.isEmpty(entity.getManagementIp())) { agent.setType(entity.getPmType()); agent.setAddress(entity.getManagementIp()); agent.setUsername(entity.getPmUser()); if (entity.getPmOptionsMap() != null) { agent.setOptions(map(entity.getPmOptionsMap(), null)); } agent.setOrder(1); model.setAgents(new Agents()); model.getAgents().getAgents().add(agent); } if (!StringUtils.isEmpty(entity.getPmSecondaryIp())) { boolean concurrent = entity.isPmSecondaryConcurrent(); model.getAgents().getAgents().get(0).setConcurrent(concurrent); agent = new Agent(); agent.setType(entity.getPmSecondaryType()); agent.setAddress(entity.getPmSecondaryIp()); agent.setUsername(entity.getPmSecondaryUser()); if (entity.getPmOptionsMap() != null) { agent.setOptions(map(entity.getPmSecondaryOptionsMap(), null)); } agent.setOrder(2); agent.setConcurrent(concurrent); model.getAgents().getAgents().add(agent); } } return model; }