下面列出了java.util.EnumSet#remove ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* This method is used to parse the {@code completionDeps} option.
* Possible modes are separated by colon; a mode can be excluded by
* prepending '-' to its name. Finally, the special mode 'all' can be used to
* add all modes to the resulting enum.
*/
static EnumSet<DependenciesMode> getDependenciesModes(String[] modes) {
EnumSet<DependenciesMode> res = EnumSet.noneOf(DependenciesMode.class);
Collection<String> args = Arrays.asList(modes);
if (args.contains("all")) {
res = EnumSet.allOf(DependenciesMode.class);
}
for (DependenciesMode mode : values()) {
if (args.contains(mode.opt)) {
res.add(mode);
} else if (args.contains("-" + mode.opt)) {
res.remove(mode);
}
}
return res;
}
void parsePatternFormatterElement(final XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException {
final EnumSet<Attribute> required = EnumSet.of(Attribute.PATTERN);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch (attribute) {
case PATTERN: {
PatternFormatterResourceDefinition.PATTERN.parseAndSetParameter(value, operation, reader);
break;
}
case COLOR_MAP: {
PatternFormatterResourceDefinition.COLOR_MAP.parseAndSetParameter(value, operation, reader);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
requireNoContent(reader);
}
public void testFlagsSizedOrderedParallelCollect() {
EnumSet<StreamOpFlag> parKnown = EnumSet.of(StreamOpFlag.SIZED);
EnumSet<StreamOpFlag> serKnown = parKnown.clone();
List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
for (StreamOpFlag f : parKnown) {
ops.add(CollectorOps.collector());
ops.add(new ParSerTestFlagExpectedOp<>(f.clear(),
parKnown,
serKnown));
serKnown.remove(f);
}
ops.add(CollectorOps.collector());
ops.add(new ParSerTestFlagExpectedOp<>(0,
parKnown,
EnumSet.noneOf(StreamOpFlag.class)));
TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
@SuppressWarnings("rawtypes")
IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);
withData(data).ops(opsArray).exercise();
}
public Set<DocumentStandardAction> getStandardActions()
{
final EnumSet<DocumentStandardAction> standardActions = EnumSet.allOf(DocumentStandardAction.class);
// Remove Clone action if not supported
if (!getEntityDescriptor().isCloneEnabled())
{
standardActions.remove(DocumentStandardAction.Clone);
}
// Remove Print action if document is not printable (https://github.com/metasfresh/metasfresh-webui-api/issues/570)
if (!getEntityDescriptor().isPrintable())
{
standardActions.remove(DocumentStandardAction.Print);
}
// Remove letter action if functionality is not enabled (https://github.com/metasfresh/metasfresh-webui-api/issues/178)
if (!Letters.isEnabled())
{
standardActions.remove(DocumentStandardAction.Letter);
}
return standardActions;
}
void parseFileElement(final ModelNode operation, final XMLExtendedStreamReader reader) throws XMLStreamException {
final EnumSet<Attribute> required = EnumSet.of(Attribute.PATH);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch (attribute) {
case PATH: {
PATH.parseAndSetParameter(value, operation, reader);
break;
}
case RELATIVE_TO: {
RELATIVE_TO.parseAndSetParameter(value, operation, reader);
break;
}
default: {
throw unexpectedAttribute(reader, i);
}
}
}
requireNoContent(reader);
}
public void testUnpackAttributes() {
EnumSet<FileAttribute> attributes = EnumSet.allOf(FileAttribute.class);
Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("RCBUGPAXT"));
attributes.remove(FileAttribute.REPLICATION);
attributes.remove(FileAttribute.CHECKSUMTYPE);
attributes.remove(FileAttribute.ACL);
attributes.remove(FileAttribute.XATTR);
Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("BUGPT"));
attributes.remove(FileAttribute.TIMES);
Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("BUGP"));
attributes.remove(FileAttribute.BLOCKSIZE);
Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("UGP"));
attributes.remove(FileAttribute.GROUP);
Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("UP"));
attributes.remove(FileAttribute.USER);
Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("P"));
attributes.remove(FileAttribute.PERMISSION);
Assert.assertEquals(attributes, DistCpUtils.unpackAttributes(""));
}
/**
* Compares the output of the optimizer run normally with a run skipping
* some optional steps. Results are printed to stderr.
*
* @param nonOptRmeth {@code non-null;} origional rop method
* @param paramSize {@code >= 0;} parameter size of method
* @param isStatic true if this method has no 'this' pointer argument.
* @param args {@code non-null;} translator arguments
* @param advice {@code non-null;} translation advice
* @param rmeth {@code non-null;} method with all optimization steps run.
*/
public static void compareOptimizerStep(RopMethod nonOptRmeth,
int paramSize, boolean isStatic, CfOptions args,
TranslationAdvice advice, RopMethod rmeth) {
EnumSet<Optimizer.OptionalStep> steps;
steps = EnumSet.allOf(Optimizer.OptionalStep.class);
// This is the step to skip.
steps.remove(Optimizer.OptionalStep.CONST_COLLECTOR);
RopMethod skipRopMethod
= Optimizer.optimize(nonOptRmeth,
paramSize, isStatic, args.localInfo, advice, steps);
int normalInsns
= rmeth.getBlocks().getEffectiveInstructionCount();
int skipInsns
= skipRopMethod.getBlocks().getEffectiveInstructionCount();
System.err.printf(
"optimize step regs:(%d/%d/%.2f%%)"
+ " insns:(%d/%d/%.2f%%)\n",
rmeth.getBlocks().getRegCount(),
skipRopMethod.getBlocks().getRegCount(),
100.0 * ((skipRopMethod.getBlocks().getRegCount()
- rmeth.getBlocks().getRegCount())
/ (float) skipRopMethod.getBlocks().getRegCount()),
normalInsns, skipInsns,
100.0 * ((skipInsns - normalInsns) / (float) skipInsns));
}
private void parseEventDays(LinkedTreeMap<String, Object> item) {
EnumSet<DayOfWeek> repetitions = EnumSet.of(DayOfWeek.FRIDAY);
repetitions.remove(DayOfWeek.FRIDAY);
ArrayList<String> eventDays = (ArrayList<String>) item.get("days");
if(eventDays.contains("MON")) {
repetitions.add(DayOfWeek.MONDAY);
}
if(eventDays.contains("TUE")) {
repetitions.add(DayOfWeek.TUESDAY);
}
if(eventDays.contains("WED")) {
repetitions.add(DayOfWeek.WEDNESDAY);
}
if(eventDays.contains("THU")) {
repetitions.add(DayOfWeek.THURSDAY);
}
if(eventDays.contains("FRI")) {
repetitions.add(DayOfWeek.FRIDAY);
}
if(eventDays.contains("SAT")) {
repetitions.add(DayOfWeek.SATURDAY);
}
if(eventDays.contains("SUN")) {
repetitions.add(DayOfWeek.SUNDAY);
}
setSelectedDays(repetitions);
}
private static Set<PartOfSpeech> buildRealTags() {
EnumSet<PartOfSpeech> reals = EnumSet.allOf(PartOfSpeech.class);
reals.remove(XX);
reals.remove(BBS);
reals.remove(BOS);
reals.remove(EOS);
return Collections.unmodifiableSet(reals);
}
protected void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException {
String propertyName = null;
String propertyValue = null;
EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch (attribute) {
case NAME: {
propertyName = value;
break;
}
case VALUE: {
propertyValue = value;
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (required.size() > 0) {
throw missingRequired(reader, required);
}
discoveryOptionProperties.add(propertyName, propertyValue);
requireNoContent(reader);
}
private void testFlagsSetSequence(Supplier<StatefulTestOp<Integer>> cf) {
EnumSet<StreamOpFlag> known = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
EnumSet<StreamOpFlag> preserve = EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED);
List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
for (StreamOpFlag f : EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(f.set(),
known.clone(),
preserve.clone(),
EnumSet.noneOf(StreamOpFlag.class)));
known.add(f);
preserve.remove(f);
}
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(0,
known.clone(),
preserve.clone(),
EnumSet.noneOf(StreamOpFlag.class)));
TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
@SuppressWarnings("rawtypes")
IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);
withData(data).ops(opsArray).
without(StreamTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
exercise();
}
public static <T extends Enum<T>> EnumSet<T> rem(Class<T> c,
EnumSet<T> set, String s) {
if (null != fullmap.get(c) && fullmap.get(c).get(s) != null) {
if (null == set) {
set = EnumSet.allOf(c);
}
set.remove(fullmap.get(c).get(s));
}
return set;
}
/**
* Compares the output of the optimizer run normally with a run skipping
* some optional steps. Results are printed to stderr.
*
* @param nonOptRmeth {@code non-null;} origional rop method
* @param paramSize {@code >= 0;} parameter size of method
* @param isStatic true if this method has no 'this' pointer argument.
* @param args {@code non-null;} translator arguments
* @param advice {@code non-null;} translation advice
* @param rmeth {@code non-null;} method with all optimization steps run.
*/
public static void compareOptimizerStep(RopMethod nonOptRmeth,
int paramSize, boolean isStatic, CfOptions args,
TranslationAdvice advice, RopMethod rmeth) {
EnumSet<Optimizer.OptionalStep> steps;
steps = EnumSet.allOf(Optimizer.OptionalStep.class);
// This is the step to skip.
steps.remove(Optimizer.OptionalStep.CONST_COLLECTOR);
RopMethod skipRopMethod
= Optimizer.optimize(nonOptRmeth,
paramSize, isStatic, args.localInfo, advice, steps);
int normalInsns
= rmeth.getBlocks().getEffectiveInstructionCount();
int skipInsns
= skipRopMethod.getBlocks().getEffectiveInstructionCount();
System.err.printf(
"optimize step regs:(%d/%d/%.2f%%)"
+ " insns:(%d/%d/%.2f%%)\n",
rmeth.getBlocks().getRegCount(),
skipRopMethod.getBlocks().getRegCount(),
100.0 * ((skipRopMethod.getBlocks().getRegCount()
- rmeth.getBlocks().getRegCount())
/ (float) skipRopMethod.getBlocks().getRegCount()),
normalInsns, skipInsns,
100.0 * ((skipInsns - normalInsns) / (float) skipInsns));
}
private void parseDiscoveryOptionProperty(XMLExtendedStreamReader reader, ModelNode discoveryOptionProperties) throws XMLStreamException {
String propertyName = null;
String propertyValue = null;
EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.VALUE);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch (attribute) {
case NAME: {
propertyName = value;
break;
}
case VALUE: {
propertyValue = value;
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (required.size() > 0) {
throw missingRequired(reader, required);
}
discoveryOptionProperties.add(propertyName, propertyValue);
requireNoContent(reader);
}
private void testFlagsSetSequence(Supplier<StatefulTestOp<Integer>> cf) {
EnumSet<StreamOpFlag> known = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
EnumSet<StreamOpFlag> preserve = EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED);
List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
for (StreamOpFlag f : EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(f.set(),
known.clone(),
preserve.clone(),
EnumSet.noneOf(StreamOpFlag.class)));
known.add(f);
preserve.remove(f);
}
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(0,
known.clone(),
preserve.clone(),
EnumSet.noneOf(StreamOpFlag.class)));
TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
@SuppressWarnings("rawtypes")
IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);
withData(data).ops(opsArray).
without(StreamTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
exercise();
}
protected void testFlagsClearSequence(Supplier<StatefulTestOp<Integer>> cf) {
EnumSet<StreamOpFlag> known = EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.SIZED);
EnumSet<StreamOpFlag> preserve = EnumSet.of(StreamOpFlag.DISTINCT, StreamOpFlag.SORTED);
EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
List<IntermediateTestOp<Integer, Integer>> ops = new ArrayList<>();
for (StreamOpFlag f : EnumSet.of(StreamOpFlag.ORDERED, StreamOpFlag.DISTINCT, StreamOpFlag.SORTED)) {
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(f.clear(),
known.clone(),
preserve.clone(),
notKnown.clone()));
known.remove(f);
preserve.remove(f);
notKnown.add(f);
}
ops.add(cf.get());
ops.add(new TestFlagExpectedOp<>(0,
known.clone(),
preserve.clone(),
notKnown.clone()));
TestData<Integer, Stream<Integer>> data = TestData.Factory.ofArray("Array", countTo(10).toArray(new Integer[0]));
@SuppressWarnings("rawtypes")
IntermediateTestOp[] opsArray = ops.toArray(new IntermediateTestOp[ops.size()]);
withData(data).ops(opsArray).
without(StreamTestScenario.PAR_STREAM_TO_ARRAY_CLEAR_SIZED).
exercise();
}
/**
* Compares the output of the optimizer run normally with a run skipping
* some optional steps. Results are printed to stderr.
*
* @param nonOptRmeth {@code non-null;} origional rop method
* @param paramSize {@code >= 0;} parameter size of method
* @param isStatic true if this method has no 'this' pointer argument.
* @param args {@code non-null;} translator arguments
* @param advice {@code non-null;} translation advice
* @param rmeth {@code non-null;} method with all optimization steps run.
*/
public static void compareOptimizerStep(RopMethod nonOptRmeth,
int paramSize, boolean isStatic, CfOptions args,
TranslationAdvice advice, RopMethod rmeth) {
EnumSet<Optimizer.OptionalStep> steps;
steps = EnumSet.allOf(Optimizer.OptionalStep.class);
// This is the step to skip.
steps.remove(Optimizer.OptionalStep.CONST_COLLECTOR);
RopMethod skipRopMethod
= Optimizer.optimize(nonOptRmeth,
paramSize, isStatic, args.localInfo, advice, steps);
int normalInsns
= rmeth.getBlocks().getEffectiveInstructionCount();
int skipInsns
= skipRopMethod.getBlocks().getEffectiveInstructionCount();
System.err.printf(
"optimize step regs:(%d/%d/%.2f%%)"
+ " insns:(%d/%d/%.2f%%)\n",
rmeth.getBlocks().getRegCount(),
skipRopMethod.getBlocks().getRegCount(),
100.0 * ((skipRopMethod.getBlocks().getRegCount()
- rmeth.getBlocks().getRegCount())
/ (float) skipRopMethod.getBlocks().getRegCount()),
normalInsns, skipInsns,
100.0 * ((skipInsns - normalInsns) / (float) skipInsns));
}
@Test
public void testPreserveOnFileUpwardRecursion() throws IOException {
FileSystem fs = FileSystem.get(config);
EnumSet<FileAttribute> attributes = EnumSet.allOf(FileAttribute.class);
// Remove ACL because tests run with dfs.namenode.acls.enabled false
attributes.remove(FileAttribute.ACL);
Path src = new Path("/tmp/src2");
Path f0 = new Path("/f0");
Path f1 = new Path("/d1/f1");
Path f2 = new Path("/d1/d2/f2");
Path d1 = new Path("/d1/");
Path d2 = new Path("/d1/d2/");
createFile(fs, src);
createFile(fs, f0);
createFile(fs, f1);
createFile(fs, f2);
fs.setPermission(src, almostFullPerm);
fs.setOwner(src, "somebody", "somebody-group");
fs.setTimes(src, 0, 0);
fs.setReplication(src, (short) 1);
fs.setPermission(d1, fullPerm);
fs.setOwner(d1, "anybody", "anybody-group");
fs.setTimes(d1, 400, 400);
fs.setReplication(d1, (short) 3);
fs.setPermission(d2, fullPerm);
fs.setOwner(d2, "anybody", "anybody-group");
fs.setTimes(d2, 300, 300);
fs.setReplication(d2, (short) 3);
fs.setPermission(f0, fullPerm);
fs.setOwner(f0, "anybody", "anybody-group");
fs.setTimes(f0, 200, 200);
fs.setReplication(f0, (short) 3);
fs.setPermission(f1, fullPerm);
fs.setOwner(f1, "anybody", "anybody-group");
fs.setTimes(f1, 200, 200);
fs.setReplication(f1, (short) 3);
fs.setPermission(f2, fullPerm);
fs.setOwner(f2, "anybody", "anybody-group");
fs.setTimes(f2, 200, 200);
fs.setReplication(f2, (short) 3);
CopyListingFileStatus srcStatus = new CopyListingFileStatus(fs.getFileStatus(src));
DistCpUtils.preserve(fs, f2, srcStatus, attributes, false);
cluster.triggerHeartbeats();
// FileStatus.equals only compares path field, must explicitly compare all fields
// attributes of src -> f2 ? should be yes
CopyListingFileStatus f2Status = new CopyListingFileStatus(fs.getFileStatus(f2));
Assert.assertTrue(srcStatus.getPermission().equals(f2Status.getPermission()));
Assert.assertTrue(srcStatus.getOwner().equals(f2Status.getOwner()));
Assert.assertTrue(srcStatus.getGroup().equals(f2Status.getGroup()));
Assert.assertTrue(srcStatus.getAccessTime() == f2Status.getAccessTime());
Assert.assertTrue(srcStatus.getModificationTime() == f2Status.getModificationTime());
Assert.assertTrue(srcStatus.getReplication() == f2Status.getReplication());
// attributes of src -> f1 ? should be no
CopyListingFileStatus f1Status = new CopyListingFileStatus(fs.getFileStatus(f1));
Assert.assertFalse(srcStatus.getPermission().equals(f1Status.getPermission()));
Assert.assertFalse(srcStatus.getOwner().equals(f1Status.getOwner()));
Assert.assertFalse(srcStatus.getGroup().equals(f1Status.getGroup()));
Assert.assertFalse(srcStatus.getAccessTime() == f1Status.getAccessTime());
Assert.assertFalse(srcStatus.getModificationTime() == f1Status.getModificationTime());
Assert.assertFalse(srcStatus.getReplication() == f1Status.getReplication());
// attributes of src -> f0 ? should be no
CopyListingFileStatus f0Status = new CopyListingFileStatus(fs.getFileStatus(f0));
Assert.assertFalse(srcStatus.getPermission().equals(f0Status.getPermission()));
Assert.assertFalse(srcStatus.getOwner().equals(f0Status.getOwner()));
Assert.assertFalse(srcStatus.getGroup().equals(f0Status.getGroup()));
Assert.assertFalse(srcStatus.getAccessTime() == f0Status.getAccessTime());
Assert.assertFalse(srcStatus.getModificationTime() == f0Status.getModificationTime());
Assert.assertFalse(srcStatus.getReplication() == f0Status.getReplication());
// attributes of src -> d2 ? should be no
CopyListingFileStatus d2Status = new CopyListingFileStatus(fs.getFileStatus(d2));
Assert.assertFalse(srcStatus.getPermission().equals(d2Status.getPermission()));
Assert.assertFalse(srcStatus.getOwner().equals(d2Status.getOwner()));
Assert.assertFalse(srcStatus.getGroup().equals(d2Status.getGroup()));
Assert.assertTrue(d2Status.getAccessTime() == 300);
Assert.assertTrue(d2Status.getModificationTime() == 300);
Assert.assertFalse(srcStatus.getReplication() == d2Status.getReplication());
// attributes of src -> d1 ? should be no
CopyListingFileStatus d1Status = new CopyListingFileStatus(fs.getFileStatus(d1));
Assert.assertFalse(srcStatus.getPermission().equals(d1Status.getPermission()));
Assert.assertFalse(srcStatus.getOwner().equals(d1Status.getOwner()));
Assert.assertFalse(srcStatus.getGroup().equals(d1Status.getGroup()));
Assert.assertTrue(d1Status.getAccessTime() == 400);
Assert.assertTrue(d1Status.getModificationTime() == 400);
Assert.assertFalse(srcStatus.getReplication() == d1Status.getReplication());
}
void parseAsyncHandlerElement(final XMLExtendedStreamReader reader, final PathAddress address, final List<ModelNode> operations, final Set<String> names) throws XMLStreamException {
final ModelNode operation = Util.createAddOperation();
// Attributes
String name = null;
final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch (attribute) {
case NAME: {
name = value;
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
if (!names.add(name)) {
throw duplicateNamedElement(reader, name);
}
// Setup the operation address
addOperationAddress(operation, address, AsyncHandlerResourceDefinition.NAME, name);
// Elements
final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
while (reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (!encountered.add(element)) {
throw unexpectedElement(reader);
}
switch (element) {
case LEVEL: {
LEVEL.parseAndSetParameter(readNameAttribute(reader), operation, reader);
break;
}
case SUBHANDLERS: {
parseHandlersElement(element.getDefinition(), operation, reader);
break;
}
case FILTER: {
parseFilter(operation, AsyncHandlerResourceDefinition.FILTER_SPEC, reader);
break;
}
case FORMATTER: {
parseHandlerFormatterElement(reader, operation);
break;
}
case QUEUE_LENGTH: {
QUEUE_LENGTH.parseAndSetParameter(readValueAttribute(reader), operation, reader);
break;
}
case OVERFLOW_ACTION: {
OVERFLOW_ACTION.parseAndSetParameter(readValueAttribute(reader).toUpperCase(Locale.US), operation, reader);
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
operations.add(operation);
}
private static void runSsaFormSteps(SsaMethod ssaMeth,
EnumSet<OptionalStep> steps) {
boolean needsDeadCodeRemover = true;
if (steps.contains(OptionalStep.MOVE_PARAM_COMBINER)) {
MoveParamCombiner.process(ssaMeth);
}
if (steps.contains(OptionalStep.SCCP)) {
SCCP.process(ssaMeth);
DeadCodeRemover.process(ssaMeth);
needsDeadCodeRemover = false;
}
if (steps.contains(OptionalStep.LITERAL_UPGRADE)) {
LiteralOpUpgrader.process(ssaMeth);
DeadCodeRemover.process(ssaMeth);
needsDeadCodeRemover = false;
}
/*
* ESCAPE_ANALYSIS impacts debuggability, so left off by default
*/
steps.remove(OptionalStep.ESCAPE_ANALYSIS);
if (steps.contains(OptionalStep.ESCAPE_ANALYSIS)) {
EscapeAnalysis.process(ssaMeth);
DeadCodeRemover.process(ssaMeth);
needsDeadCodeRemover = false;
}
if (steps.contains(OptionalStep.CONST_COLLECTOR)) {
ConstCollector.process(ssaMeth);
DeadCodeRemover.process(ssaMeth);
needsDeadCodeRemover = false;
}
// dead code remover must be run before phi type resolver
if (needsDeadCodeRemover) {
DeadCodeRemover.process(ssaMeth);
}
PhiTypeResolver.process(ssaMeth);
}