class PowerShellVmsResource { enum Method { GET, ADD }; enum Detail { DISKS("$_.getmemorystatistics(); $_.getcpustatistics(); "), STATISTICS("$_.getdiskimages(); "); public final String powershell; Detail(String powershell) { this.powershell = powershell; } } static String getProcess(Method method, Set details) { StringBuilder buf = new StringBuilder(); if (details != null) { for (Detail detail : details) { buf.append(detail.powershell); } } return MessageFormat.format(PROCESS_VMS, method == Method.ADD ? " " : "$_; ", buf); } private String getProcess(Method method) { return getProcess(method, getDetails()); } private Set getDetails() { Set details = new EnumSet(); for (Detail detail : Detail.class.getEnumConstants()) { if (include(getHttpHeaders(), detail.name().toLowerCase())) { details.add(detail); } } return details; } }