Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Copyright (C) 2011-2014 Rinde van Lon, iMinds DistriNet, KU Leuven
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package com.github.rinde.rinsim.scenario.measure;
import static;
A that evaluates to true if the input scenario has a number of orders in the range as specified by this instance. An order is specified by a com.github.rinde.rinsim.scenario.AddParcelEvent.

Rinde van Lon <>
  private final int min;
  private final int max;

Range constructor, only accepts scenarios that have a number of orders that is in the range [minNumOrders,maxNumOrders].

minNumOrders Minimum number of orders.
maxNumOrders Maximum number of orders.
  OrderCountRequirement(int minNumOrdersint maxNumOrders) {
    checkArgument(minNumOrders <= maxNumOrders);
     = minNumOrders;
     = maxNumOrders;

Exact constructor, only accepts scenarios that have exactly the specified number of orders.

orders The number of orders.
  OrderCountRequirement(int orders) {
  public boolean apply(@Nullable Scenario input) {
    if (input == null) {
      return false;
    final int numOrders = Collections.frequency(
            new ToClassFunction()), AddParcelEvent.class);
    return numOrders >=  && numOrders <= ;
  private static final class ToClassFunction implements
      Function<ObjectClass<?>> {
    public Class<?> apply(@Nullable Object obj) {
      if (obj == null) {
        return null;
      return obj.getClass();
New to GrepCode? Check out our FAQ X