Set<EffectQuantum> (Effects effects, DataValue[] data, boolean isStatic) { if (effects.effects.isEmpty() || Effects.TOP_EFFECTS.equals(effects.effects)) { return effects.effects; } Set<EffectQuantum> newEffects = new HashSet<>(effects.effects.size()); int shift = isStatic ? 0 : 1; for (EffectQuantum effect : effects.effects) { DataValue arg = null; if (effect == EffectQuantum.ThisChangeQuantum) { arg = data[0]; } else if (effect instanceof EffectQuantum.ParamChangeQuantum paramChange) { arg = data[paramChange.n + shift]; } if (arg == null || arg == DataValue.LocalDataValue) { continue; } if (arg == DataValue.ThisDataValue || arg == DataValue.OwnedDataValue) { newEffects.add(EffectQuantum.ThisChangeQuantum); continue; } if (arg instanceof DataValue.ParameterDataValue) { newEffects.add(new EffectQuantum.ParamChangeQuantum(((DataValue.ParameterDataValue)arg).n)); continue; } if (arg instanceof DataValue.ReturnDataValue) { newEffects.add(new EffectQuantum.ReturnChangeQuantum(((DataValue.ReturnDataValue)arg).key)); continue; } return Effects.TOP_EFFECTS; } return newEffects; }