Convenient way to reuse logic of checking for the build status

@param result to check against
@param state  state to set
@param msg    message to set. Can contain env vars

@return new instance of this conditional result
353775
public static BetterThanOrEqualBuildResult betterThanOrEqualTo(Result result, GHCommitState state, String msg) {
        BetterThanOrEqualBuildResult conditional = new BetterThanOrEqualBuildResult();
        conditional.setResult(result.toString());
        conditional.setState(state.name());
        conditional.setMessage(msg);
        return conditional;
    }
1038701
@Override
    public StatusResult get(@Nonnull Run<?, ?> run, @Nonnull TaskListener listener)
            throws IOException, InterruptedException {

        for (ConditionalResult conditionalResult : getResults()) {
            if (conditionalResult.matches(run)) {
                return new StatusResult(
                        defaultIfNull(EnumUtils.getEnum(GHCommitState.class, conditionalResult.getState()), ERROR),
                        new ExpandableMessage(conditionalResult.getMessage()).expandAll(run, listener)
                );
            }
        }

        return new StatusResult(
                PENDING,
                new ExpandableMessage("Can't define which status to set").expandAll(run, listener)
        );
    }
533560
function(errOrMessage, result) {
        var err = (errOrMessage instanceof Error) ? errOrMessage : new Error(errOrMessage);
        result = result || {};
        result.error = err;
        result.status = 'error';
        err.result = result;
        return err;
    }
872886
public static alluxio.proto.journal.Job.TaskInfo.Builder setResult(
          alluxio.proto.journal.Job.TaskInfo.Builder builder, byte[] bytes) {
    return builder.setResult(com.google.protobuf.ByteString.copyFrom(bytes));
  }
492880
public ChatResult adaptResult(ComapiResult<?> result) {

        return new ChatResult(result.isSuccessful(), result.isSuccessful() ? null : new ChatResult.Error(result));
    }
45487
boolean success(T result) {
        State<T> oldState;
        synchronized (mutex) {
            if (state.isCompleted()) {
                return false;
            }
            oldState = state;
            state = state.getSuccessState(result);
        }
        oldState.callSuccessCallbacks(result);
        return true;

    }
1162576
public boolean copyMessageToResult(javax.xml.transform.Result resultTarget)
   {
       Node tree = this.getDOM();
       return Utility.copyTreeToResult(tree, resultTarget);
   }
819167
public static void shutdownActive(ShutdownModeAmp mode,
                                    ExitCode exitCode, 
                                    String msg,
                                    Result<String> result)
  {
    ShutdownSystem shutdown = _activeService.get();
    
    if (shutdown != null) {
      shutdown.shutdown(mode, exitCode, msg, result);
      return;
    }
    
    shutdown = getCurrent();
    
    if (shutdown != null) {
      shutdown.shutdown(mode, exitCode, msg, result);
      return;
    }
    
    msg = ShutdownSystem.class.getSimpleName() + " is not active:\n  " + msg;
    
    log.warning(msg);
    System.out.println(msg);
    
    if (result != null) {
      result.ok(msg);
    }
  }
801665
def store_result(self, message, result: Result, ttl: int) -> None:
        
        message_key = self.build_message_key(message)
        return self._store(message_key, result, ttl)
1027908
public static Object buildSingleResult(Result result, int column,
			GeoPackageDataType dataType) {

		Object value = null;
		try {
			if (result.moveToNext()) {
				value = result.getValue(column, dataType);
			}
		} finally {
			result.close();
		}

		return value;
	}
623760
public ExecutionResult withResult(Object result) {
    return new ExecutionResult(result, null, nonResult, waitNanos, true, true, successAll);
  }
431955
@SuppressWarnings("unchecked")
    private void updateContextWithResults(final MessageContext messageContext, final WSHandlerResult result) {
        List<WSHandlerResult> handlerResults;
        if ((handlerResults = (List<WSHandlerResult>) messageContext.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
            handlerResults = new ArrayList<WSHandlerResult>();
            messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults);
        }
        handlerResults.add(0, result);
        messageContext.setProperty(WSHandlerConstants.RECV_RESULTS, handlerResults);
    }
1191397
public String buildResultsInfoMessage(FeatureIndexResults results, double tolerance, LatLng clickLocation) {
        return buildResultsInfoMessage(results, tolerance, clickLocation, null);
    }
774556
public void addResult(CmsResourceTypeStatResult result) {

        if (!m_results.contains(result)) {
            m_results.add(result);
            m_updated = false;
        } else {
            m_results.remove(result);
            m_results.add(result);
            m_updated = true;
        }
    }
506658
private void buildErrorStatus(BatchResult result, Throwable ex) {
        result.setStatus(BatchResult.Status.ERROR);
        result.setErrorMessage(ex.getLocalizedMessage());
        if (ex instanceof IllegalArgumentException) {
            m_logger.debug("Batch update error: {}", ex.toString());
        } else {
            result.setStackTrace(Utils.getStackTrace(ex));
            m_logger.debug("Batch update error: {} stacktrace: {}",
                           ex.toString(), Utils.getStackTrace(ex));
        }
    }
49610
public void onSuccess(T result) {
        try {
            statusLock.lock();
            value = result;
            status = new RequestStatus(RequestStatusCode.OK);
            statusLockChangedCondition.signalAll();
        } catch (Exception e) {
            status = new RequestStatus(RequestStatusCode.ERROR);
            exception = new JoynrRuntimeException(e);
        } finally {
            statusLock.unlock();
        }
    }
92314
public void setResult(Result result) throws IllegalArgumentException
  {
    if(null == result)
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_NULL, null)); //"Result should not be null");        
    m_result = result;
  }