Created
February 22, 2011 12:08
-
-
Save markmc/838574 to your computer and use it in GitHub Desktop.
New getProcess() method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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