The main MaxSAT solving method.
@param handler a MaxSAT handler
@return the result of the solving process
@throws IllegalArgumentException if the configuration was not valid
503927
public final MaxSATResult search(final MaxSATHandler handler) {
    this.handler = handler;
    if (handler != null)
      handler.startedSolving();
    final MaxSATResult result = search();
    if (handler != null)
      handler.finishedSolving();
    this.handler = null;
    return result;
  }
1002179
public int receive(final MessageHandler handler)
    {
        int messagesReceived = 0;
        final BroadcastReceiver receiver = this.receiver;
        final long lastSeenLappedCount = receiver.lappedCount();

        if (receiver.receiveNext())
        {
            if (lastSeenLappedCount != receiver.lappedCount())
            {
                throw new IllegalStateException("unable to keep up with broadcast");
            }

            final int length = receiver.length();
            final int capacity = scratchBuffer.capacity();
            if (length > capacity && !scratchBuffer.isExpandable())
            {
                throw new IllegalStateException(
                    "buffer required length of " + length + " but only has " + capacity);
            }

            final int msgTypeId = receiver.typeId();
            scratchBuffer.putBytes(0, receiver.buffer(), receiver.offset(), length);

            if (!receiver.validate())
            {
                throw new IllegalStateException("unable to keep up with broadcast");
            }

            handler.onMessage(msgTypeId, scratchBuffer, 0, length);

            messagesReceived = 1;
        }

        return messagesReceived;
    }
1039946
public static <T, U> BiPredicate<T, U> biPredicate(CheckedBiPredicate<T, U> predicate, Consumer<Throwable> handler) {
        return (t, u) -> {
            try {
                return predicate.test(t, u);
            }
            catch (Throwable e) {
                handler.accept(e);

                throw new IllegalStateException("Exception handler must throw a RuntimeException", e);
            }
        };
    }
1357692
@SuppressWarnings("rawtypes")
    public static List<Handler> sortHandlers(List<Handler> handlers) {

        List<LogicalHandler<?>> logicalHandlers = new ArrayList<LogicalHandler<?>>();
        List<Handler<?>> protocolHandlers = new ArrayList<Handler<?>>();

        for (Handler<?> handler : handlers) {
            if (handler instanceof LogicalHandler) {
                logicalHandlers.add((LogicalHandler<?>) handler);
            } else {
                protocolHandlers.add(handler);
            }
        }

        List<Handler> sortedHandlers = new ArrayList<Handler>(logicalHandlers.size() + protocolHandlers.size());
        sortedHandlers.addAll(logicalHandlers);
        sortedHandlers.addAll(protocolHandlers);
        return sortedHandlers;
    }
192210
public JsHandlerRegistration addGeometryEditStartHandler(final GeometryEditStartHandler handler) {
		org.geomajas.plugin.editing.client.event.GeometryEditStartHandler h;
		h = new org.geomajas.plugin.editing.client.event.GeometryEditStartHandler() {

			public void onGeometryEditStart(GeometryEditStartEvent event) {
				handler.onGeometryEditStart(new org.geomajas.plugin.editing.jsapi.client.event.GeometryEditStartEvent(
						event.getGeometry()));
			}
		};
		return new JsHandlerRegistration(new HandlerRegistration[] { delegate.addGeometryEditStartHandler(h) });
	}
652700
@SuppressWarnings("unchecked")
  public S execute(S solution) {
    int best;
    evaluations = 0;
    numberOfNonComparableSolutions = 0;

    int rounds = improvementRounds;

    int i = 0;
    while (i < rounds) {
      S mutatedSolution = mutationOperator.execute((S) solution.copy());

      problem.evaluate(mutatedSolution);
      evaluations++;
      if (problem.getNumberOfConstraints() > 0) {
        best = constraintComparator.compare(mutatedSolution, solution);
        if (best == 0) {
          best = comparator.compare(mutatedSolution, solution);
        }
      } else {
        best = comparator.compare(mutatedSolution, solution);
      }

      if (best == -1) {
        solution = mutatedSolution;
        numberOfImprovements++;
      } else if (best == 1) {
        // Current solution is best
      } else {
        numberOfNonComparableSolutions++;

        if (randomGenerator.getRandomValue() < 0.5) {
          solution = mutatedSolution;
        }
      }
      i++;
    }
    return (S) solution.copy();
  }
532837
public Router get(@NotNull final Pattern regex, @NotNull final Handler<YokeRequest> handler) {
        return get(regex, new Middleware() {
            @Override
            public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
                handler.handle(request);
            }
        });
    }
1046273
private static <T, U> U convertBean(T source, Class<U> targetClass, Handler handler) {
        try {
            if (Objects.isNull(source)) {
                return null;
            }
            return targetClass.cast(handler.getMethod().invoke(handler.getHandler(), source));
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw ConvertException.of("Call method \"" + handler.getMethod() + "\" failed", e);
        }
    }
565968
public List<Assignment> enumerateAllModels(final ModelEnumerationHandler handler) {
        return this.enumerateAllModels((Collection<Variable>) null, handler);
    }
438798
public RouteMatcher patch(String pattern, Handler<HttpServerRequest> handler) {
		addPattern(pattern, handler, patchBindings);
		return this;
	}
761182
@Override
  public void registerErrorHandler(final EventHandler<Exception> handler) {
    this.clientEventListener.registerErrorHandler(handler);
    this.serverEventListener.registerErrorHandler(handler);
  }
753262
public static void parse (DefaultHandler handler, InputStream in)
        throws IOException, ParserConfigurationException, SAXException
    {
        XMLReader xr = _pfactory.newSAXParser().getXMLReader();

        xr.setContentHandler(handler);
        xr.setErrorHandler(handler);

        xr.parse(new InputSource(in));
    }
919427
@Nonnull
	public final LToLongFunctionBuilder<T> withHandling(@Nonnull HandlingInstructions<RuntimeException, RuntimeException> handling) {
		Null.nonNullArg(handling, "handling");
		if (this.handling != null) {
			throw new UnsupportedOperationException("Handling is already set for this builder.");
		}
		this.handling = handling;
		return self();
	}
903813
@Override
	public int getMaxLength() {
		int max = 0;
		boolean found = false;
		for (Constraint c : constraints) {
			int cM = c.getMaxLength();
			if (cM != -1) {
				max += cM;
				found = true;
			}
		}
		return found ? max : -1;
	}
997149
private static void initStringDefinedHandler(String handler) {
		// split the class name and its label, if defined
		Tuple<String, Class> namedClass = splitClassAndName(handler);

		// create an instance of the handler
		Object handlerOrProviderObject = null;
		try {
			handlerOrProviderObject = namedClass.second.newInstance();
		} catch (Exception e) {
			logger.error("Exception:", e);
			throw new RuntimeException("Could not instantiate handler class: " + namedClass.second);
		}

		HttpHandler resolvedHandler;
		if (handlerOrProviderObject instanceof HttpHandler) {
			resolvedHandler = (HttpHandler) handlerOrProviderObject;
		} else if (handlerOrProviderObject instanceof HandlerProvider) {
			resolvedHandler = ((HandlerProvider) handlerOrProviderObject).getHandler();
		} else {
			throw new RuntimeException("Unsupported type of handler provided: " + handlerOrProviderObject);
		}
		registerMiddlewareHandler(resolvedHandler);
		handlers.put(namedClass.first, resolvedHandler);
		handlerListById.put(namedClass.first, Collections.singletonList(resolvedHandler));
	}
621285
public JsHandlerRegistration addGeometryEditStopHandler(final GeometryEditStopHandler handler) {
		org.geomajas.plugin.editing.client.event.GeometryEditStopHandler h;
		h = new org.geomajas.plugin.editing.client.event.GeometryEditStopHandler() {

			public void onGeometryEditStop(GeometryEditStopEvent event) {
				handler.onGeometryEditStop(new org.geomajas.plugin.editing.jsapi.client.event.GeometryEditStopEvent(
						event.getGeometry()));
			}
		};
		return new JsHandlerRegistration(new HandlerRegistration[] { delegate.addGeometryEditStopHandler(h) });
	}
334608
public AioSession read(CompletionHandler<Integer, AioSession> handler) {
		if (isOpen()) {
			this.readBuffer.clear();
			this.channel.read(this.readBuffer, Math.max(this.readTimeout, 0L), TimeUnit.MILLISECONDS, this, handler);
		}
		return this;
	}