Skip to content

Instantly share code, notes, and snippets.

@markmc
Created February 22, 2011 12:08
Show Gist options
  • Save markmc/838574 to your computer and use it in GitHub Desktop.
Save markmc/838574 to your computer and use it in GitHub Desktop.
New getProcess() method
class PowerShellVmsResource {
enum Method { GET, ADD };
enum Detail { DISKS, STATISTICS };
static String getProcess(Method method, Set<Detail> details) {
StringBuilder buf = new StringBuilder();
if (details != null) {
if (details.contains(Detail.DISKS)) {
buf.append(GET_STATS);
}
if (details.contains(Detail.STATISTICS)) {
buf.append(GET_DISKS);
}
}
return MessageFormat.format(PROCESS_VMS, method == Method.ADD ? " " : "$_; ", buf);
}
private String getProcess(Method method) {
return getProcess(method, getDetails());
}
private Set<Details> getDetails() {
Set<Detail> details = EnumSet.noneOf(Detail.class);
for (Detail detail : Detail.class.getEnumConstants()) {
if (include(getHttpHeaders(), detail.name().toLowerCase())) {
details.add(detail);
}
}
return details;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment