Java Code Examples for java.util.EnumSet#addAll()

The following examples show how to use java.util.EnumSet#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AllGroupSelector.java    From Dividers with Apache License 2.0 6 votes vote down vote up
@Override public EnumSet<Direction> getDirectionsByPosition(Position position) {
  EnumSet<Direction> directions = EnumSet.noneOf(Direction.class);

  if (position.isFirstRow()) {
    directions.addAll(Arrays.asList(Direction.NORTH_WEST, Direction.NORTH, Direction.NORTH_EAST));
  }
  if (position.isLastRow()) {
    directions.addAll(Arrays.asList(Direction.SOUTH_WEST, Direction.SOUTH, Direction.SOUTH_EAST));
  }
  if (position.isFirstColumn()) {
    directions.addAll(Arrays.asList(Direction.SOUTH_WEST, Direction.WEST, Direction.NORTH_WEST));
  }
  if (position.isLastColumn()) {
    directions.addAll(Arrays.asList(Direction.NORTH_EAST, Direction.EAST, Direction.SOUTH_EAST));
  }

  return directions;
}
 
Example 2
Source File: HeaderQuestion.java    From batfish with Apache License 2.0 5 votes vote down vote up
@JsonProperty(PROP_BGP_RANKING)
public void setBgpRanking(List<BgpDecisionVariable> r) {

  EnumSet<BgpDecisionVariable> rset = EnumSet.noneOf(BgpDecisionVariable.class);
  rset.addAll(r);
  if (rset.size() != r.size()) {
    throw new BatfishException("Duplicate BGP decision variable in question");
  }
  _bgpRanking = r;
}
 
Example 3
Source File: MCNetworkRail.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
private static EnumSet<EnumHeading> getValidHeadings(EnumSet<EnumRailDirection> validRailDirs){
    EnumSet<EnumHeading> headings = EnumSet.noneOf(EnumHeading.class);
    for(EnumRailDirection dir : validRailDirs) {
        headings.addAll(getDirections(dir));
    }
    return headings;
}
 
Example 4
Source File: TestRealms.java    From es6draft with MIT License 5 votes vote down vote up
private static void optionsFromMode(EnumSet<CompatibilityOption> options, String mode) {
    switch (mode) {
    case "moz-compatibility":
        options.addAll(CompatibilityOption.MozCompatibility());
        break;
    case "web-compatibility":
        options.addAll(CompatibilityOption.WebCompatibility());
        break;
    case "strict-compatibility":
        options.addAll(CompatibilityOption.StrictCompatibility());
        break;
    default:
        throw new IllegalArgumentException(String.format("Unsupported mode: '%s'", mode));
    }
}
 
Example 5
Source File: FunctionNode.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy a compilation state from an original function to this function. Used when creating synthetic
 * function nodes by the splitter.
 *
 * @param lc lexical context
 * @param original the original function node to copy compilation state from
 * @return function node or a new one if state was changed
 */
public FunctionNode copyCompilationState(final LexicalContext lc, final FunctionNode original) {
    final EnumSet<CompilationState> origState = original.compilationState;
    if (!AssertsEnabled.assertsEnabled() || this.compilationState.containsAll(origState)) {
        return this;
    }
    final EnumSet<CompilationState> newState = EnumSet.copyOf(this.compilationState);
    newState.addAll(origState);
    return setCompilationState(lc, newState);
}
 
Example 6
Source File: AnalysisFilterJS.java    From nodeprof.js with Apache License 2.0 5 votes vote down vote up
@TruffleBoundary
private static EnumSet<ProfiledTagEnum> mapToTags(Object[] callbacks) {
    EnumSet<ProfiledTagEnum> set = EnumSet.noneOf(ProfiledTagEnum.class);
    for (Object cb : callbacks) {
        EnumSet<ProfiledTagEnum> tags = JalangiAnalysis.callbackMap.get(cb.toString());
        if (tags == null) {
            Logger.error("JS Analysis filter predicate returned non-Jalangi callback: " + cb);
        } else {
            set.addAll(tags);
        }
    }
    return set;
}
 
Example 7
Source File: DefaultRouter.java    From vraptor4 with Apache License 2.0 5 votes vote down vote up
@Override
public EnumSet<HttpMethod> allowedMethodsFor(String uri) {
	EnumSet<HttpMethod> allowed = EnumSet.noneOf(HttpMethod.class);
	for (Route route : routesMatchingUri(uri)) {
		allowed.addAll(route.allowedMethods());
	}
	return allowed;
}
 
Example 8
Source File: TestRealms.java    From es6draft with MIT License 5 votes vote down vote up
private static void optionsFromStage(EnumSet<CompatibilityOption> options, String stage) {
    options.addAll(Arrays.stream(CompatibilityOption.Stage.values()).filter(s -> {
        if (stage.length() == 1 && Character.isDigit(stage.charAt(0))) {
            return s.getLevel() == Character.digit(stage.charAt(0), 10);
        } else {
            return s.name().equalsIgnoreCase(stage);
        }
    }).findAny().map(CompatibilityOption::Stage).orElseThrow(IllegalArgumentException::new));
}
 
Example 9
Source File: GradleCommandLine.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean canAdd(Flag f) {
    EnumSet<Flag> reserved = EnumSet.noneOf(Flag.class);
    Iterator<Argument> it = arguments.iterator();
    while (it.hasNext()) {
        Argument arg = it.next();
        if (arg instanceof FlagArgument) {
            FlagArgument farg = (FlagArgument) arg;
            reserved.add(farg.flag);
            reserved.addAll(farg.flag.incompatible);
        }
    }
    return !reserved.contains(f);
}
 
Example 10
Source File: BlipMetaDomImpl.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public void enable(Set<MenuOption> toEnable) {
  Pair<EnumMap<MenuOption, BlipMenuItemDomImpl>, EnumSet<MenuOption>>  state = getMenuState();
  EnumSet<MenuOption> options = EnumSet.copyOf(state.first.keySet());
  EnumSet<MenuOption> selected = state.second;
  options.addAll(toEnable);
  setMenuState(options, selected);
}
 
Example 11
Source File: HttpdLogFormatDissector.java    From logparser with Apache License 2.0 5 votes vote down vote up
@Override
public EnumSet<Casts> prepareForDissect(String inputname, String outputname) {
    if (dissectors.isEmpty()) {
        return NO_CASTS;
    }

    EnumSet<Casts> result = EnumSet.noneOf(Casts.class); // Start empty
    for (Dissector dissector : dissectors) {
        result.addAll(dissector.prepareForDissect(inputname, outputname));
    }
    return result;
}
 
Example 12
Source File: CompositeValueClass.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected EnumSet<OperandFlag> getFlags(Field field) {
    EnumSet<OperandFlag> result = EnumSet.noneOf(OperandFlag.class);
    if (field.isAnnotationPresent(CompositeValue.Component.class)) {
        result.addAll(Arrays.asList(field.getAnnotation(CompositeValue.Component.class).value()));
    } else {
        GraalError.shouldNotReachHere();
    }
    return result;
}
 
Example 13
Source File: Type.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/** replace types in all bounds - this might trigger listener notification */
public void substBounds(List<Type> from, List<Type> to, Types types) {
    List<Type> instVars = from.diff(to);
    //if set of instantiated ivars is empty, there's nothing to do!
    if (instVars.isEmpty()) return;
    final EnumSet<InferenceBound> boundsChanged = EnumSet.noneOf(InferenceBound.class);
    UndetVarListener prevListener = listener;
    try {
        //setup new listener for keeping track of changed bounds
        listener = new UndetVarListener() {
            public void varChanged(UndetVar uv, Set<InferenceBound> ibs) {
                boundsChanged.addAll(ibs);
            }
        };
        for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
            InferenceBound ib = _entry.getKey();
            List<Type> prevBounds = _entry.getValue();
            ListBuffer<Type> newBounds = new ListBuffer<>();
            ListBuffer<Type> deps = new ListBuffer<>();
            //step 1 - re-add bounds that are not dependent on ivars
            for (Type t : prevBounds) {
                if (!t.containsAny(instVars)) {
                    newBounds.append(t);
                } else {
                    deps.append(t);
                }
            }
            //step 2 - replace bounds
            bounds.put(ib, newBounds.toList());
            //step 3 - for each dependency, add new replaced bound
            for (Type dep : deps) {
                addBound(ib, types.subst(dep, from, to), types, true);
            }
        }
    } finally {
        listener = prevListener;
        if (!boundsChanged.isEmpty()) {
            notifyChange(boundsChanged);
        }
    }
}
 
Example 14
Source File: ScheduleEditController.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
public void enableRepetitions(Set<DayOfWeek> days) {
    EnumSet<DayOfWeek> repetitions = EnumSet.of(editingDay);
    repetitions.addAll(days);
    setPoint.setRepeatsOn(repetitions);
    setPoint.setRepetitionText(ScheduleUtils.generateRepeatsText(days));
}
 
Example 15
Source File: Client.java    From desktopclient-java with GNU General Public License v3.0 4 votes vote down vote up
private EnumSet<FeatureDiscovery.Feature> getServerFeature() {
    EnumSet<FeatureDiscovery.Feature> e = EnumSet.noneOf(FeatureDiscovery.Feature.class);
    e.addAll(mFeatures.keySet());
    return e;
}
 
Example 16
Source File: Collectors.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
private static <T, A1, A2, R1, R2, R>
Collector<T, ?, R> teeing0(Collector<? super T, A1, R1> downstream1,
                           Collector<? super T, A2, R2> downstream2,
                           BiFunction<? super R1, ? super R2, R> merger) {
    Objects.requireNonNull(downstream1, "downstream1");
    Objects.requireNonNull(downstream2, "downstream2");
    Objects.requireNonNull(merger, "merger");

    Supplier<A1> c1Supplier = Objects.requireNonNull(downstream1.supplier(), "downstream1 supplier");
    Supplier<A2> c2Supplier = Objects.requireNonNull(downstream2.supplier(), "downstream2 supplier");
    BiConsumer<A1, ? super T> c1Accumulator =
            Objects.requireNonNull(downstream1.accumulator(), "downstream1 accumulator");
    BiConsumer<A2, ? super T> c2Accumulator =
            Objects.requireNonNull(downstream2.accumulator(), "downstream2 accumulator");
    BinaryOperator<A1> c1Combiner = Objects.requireNonNull(downstream1.combiner(), "downstream1 combiner");
    BinaryOperator<A2> c2Combiner = Objects.requireNonNull(downstream2.combiner(), "downstream2 combiner");
    Function<A1, R1> c1Finisher = Objects.requireNonNull(downstream1.finisher(), "downstream1 finisher");
    Function<A2, R2> c2Finisher = Objects.requireNonNull(downstream2.finisher(), "downstream2 finisher");

    Set<Collector.Characteristics> characteristics;
    Set<Collector.Characteristics> c1Characteristics = downstream1.characteristics();
    Set<Collector.Characteristics> c2Characteristics = downstream2.characteristics();
    if (CH_ID.containsAll(c1Characteristics) || CH_ID.containsAll(c2Characteristics)) {
        characteristics = CH_NOID;
    } else {
        EnumSet<Collector.Characteristics> c = EnumSet.noneOf(Collector.Characteristics.class);
        c.addAll(c1Characteristics);
        c.retainAll(c2Characteristics);
        c.remove(Collector.Characteristics.IDENTITY_FINISH);
        characteristics = Collections.unmodifiableSet(c);
    }

    class PairBox {
        A1 left = c1Supplier.get();
        A2 right = c2Supplier.get();

        void add(T t) {
            c1Accumulator.accept(left, t);
            c2Accumulator.accept(right, t);
        }

        PairBox combine(PairBox other) {
            left = c1Combiner.apply(left, other.left);
            right = c2Combiner.apply(right, other.right);
            return this;
        }

        R get() {
            R1 r1 = c1Finisher.apply(left);
            R2 r2 = c2Finisher.apply(right);
            return merger.apply(r1, r2);
        }
    }

    return new CollectorImpl<>(PairBox::new, PairBox::add, PairBox::combine, PairBox::get, characteristics);
}
 
Example 17
Source File: ScriptLoading.java    From es6draft with MIT License 4 votes vote down vote up
private static ScriptLoader createNativeScriptLoader(RuntimeContext context) {
    EnumSet<Parser.Option> nativeOptions = EnumSet.of(Parser.Option.NativeCall, Parser.Option.NativeFunction);
    nativeOptions.addAll(context.getParserOptions());
    return new ScriptLoader(new RuntimeContext.Builder(context).setParserOptions(nativeOptions).build());
}
 
Example 18
Source File: Type.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** replace types in all bounds - this might trigger listener notification */
public void substBounds(List<Type> from, List<Type> to, Types types) {
    List<Type> instVars = from.diff(to);
    //if set of instantiated ivars is empty, there's nothing to do!
    if (instVars.isEmpty()) return;
    final EnumSet<InferenceBound> boundsChanged = EnumSet.noneOf(InferenceBound.class);
    UndetVarListener prevListener = listener;
    try {
        //setup new listener for keeping track of changed bounds
        listener = new UndetVarListener() {
            public void varChanged(UndetVar uv, Set<InferenceBound> ibs) {
                boundsChanged.addAll(ibs);
            }
        };
        for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
            InferenceBound ib = _entry.getKey();
            List<Type> prevBounds = _entry.getValue();
            ListBuffer<Type> newBounds = new ListBuffer<>();
            ListBuffer<Type> deps = new ListBuffer<>();
            //step 1 - re-add bounds that are not dependent on ivars
            for (Type t : prevBounds) {
                if (!t.containsAny(instVars)) {
                    newBounds.append(t);
                } else {
                    deps.append(t);
                }
            }
            //step 2 - replace bounds
            bounds.put(ib, newBounds.toList());
            //step 3 - for each dependency, add new replaced bound
            for (Type dep : deps) {
                addBound(ib, types.subst(dep, from, to), types, true);
            }
        }
    } finally {
        listener = prevListener;
        if (!boundsChanged.isEmpty()) {
            notifyChange(boundsChanged);
        }
    }
}
 
Example 19
Source File: EnumSetParam.java    From big-c with Apache License 2.0 4 votes vote down vote up
static <E extends Enum<E>> EnumSet<E> toEnumSet(final Class<E> clazz,
    final E... values) {
  final EnumSet<E> set = EnumSet.noneOf(clazz);
  set.addAll(Arrays.asList(values));
  return set;
}
 
Example 20
Source File: ScriptTest.java    From es6draft with MIT License 4 votes vote down vote up
@Override
protected EnumSet<CompatibilityOption> getOptions() {
    EnumSet<CompatibilityOption> options = super.getOptions();
    options.addAll(CompatibilityOption.Experimental());
    return options;
}