Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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