Returns the longest command that can be matched as first word(s) in the given buffer.

@return a valid command name, or {@literal null} if none matched
557527
private String findLongestCommand(String prefix) {
		String result = methodTargets.keySet().stream()
				.filter(command -> prefix.equals(command) || prefix.startsWith(command + " "))
				.reduce("", (c1, c2) -> c1.length() > c2.length() ? c1 : c2);
		return "".equals(result) ? null : result;
	}
144362
public Command findCommand(String name) {
		for (Command candidate : this.commands) {
			String candidateName = candidate.getName();
			if (candidateName.equals(name) || (isOptionCommand(candidate)
					&& ("--" + candidateName).equals(name))) {
				return candidate;
			}
		}
		return null;
	}
941446
public String next() {
        if (fifo.isEmpty()) {
            throw new RuntimeException("Fifo is empty");
        }
        String cmd = (String) fifo.get(0);
        fifo.remove(0);
        return cmd;
    }
812832
public static <V> int longestKeyLength(Map<String, V> map) {
    if (map.isEmpty()) {
      return 0;
    }

    return Ordering.natural().max(
        FluentIterable.from(map.keySet())
            .transform(StringUtils.lengthFunction()));
  }
201288
public String getFirst(String key)
    {
        if(key == null)
            throw new IllegalArgumentException("Null keys not allowed.");

        List<String> vals = map.get(key);
        if(vals == null || vals.size() == 0)
            return null;

        return vals.get(0);
    }
52145
def _get_command_buffer(self, host_id, command_name):
        """"""
        buf = self._cb_poll.get(host_id)
        if buf is not None:
            return buf

        if self._max_concurrency is not None:
            while len(self._cb_poll) >= self._max_concurrency:
                self.join(timeout=1.0)

        def connect():
            return self.connection_pool.get_connection(
                command_name, shard_hint=host_id)
        buf = CommandBuffer(host_id, connect, self.auto_batch)
        self._cb_poll.register(host_id, buf)
        return buf
728553
public CommandOption<T> longCommand(String longName) {

		Assert.notNullOrEmptyTrimmed(longName, "Missing long name!");

		longName = StringUtils.trim(longName);
		Assert.isTrue(command.length() <= longName.length(), "Long name can't be shorter than command name!");

		String compare = StringUtils.sanitizeWhitespace(longName);
		Assert.isTrue(longName.equals(compare), "Option long name can not contain whitespace characters!");

		longCommand = longName;
		return this;
	}
239934
public CommandOption findLong(String argument) {

		Assert.notNullOrEmptyTrimmed(argument, "Missing long name!");

		Optional<CommandOption> found = options.stream().filter(o -> o.isLong(argument)).findFirst();
		return found.orElse(null);
	}
442131
protected static String runCommand (String cmd)
    {
        try {
            Process p = Runtime.getRuntime().exec(cmd);
            BufferedReader cin = new BufferedReader(new InputStreamReader(p.getInputStream()));
            StringBuilder buffer= new StringBuilder();

            String line = "";
            while (line != null)
            {
                buffer.append(line);
                line = cin.readLine();
            }
            cin.close();

            return buffer.toString();
        } catch (IOException e) {
            // don't want to log anything for the client to know what we are doing.
            // This will almost always be thrown/caught when the cmd isn't there.
            return null;
        }
    }
133544
public static String getFirstUpperName(String name) {
        if (StringUtils.isBlank(name)) {
            return null;
        }
        String firstChar = name.substring(0, 1).toUpperCase();
        return firstChar + name.substring(1);
    }
331484
protected String extractFirstName(String name) {
    if (StringUtils.isBlank(name)) {
      return null;
    }
    
    int lastIndexOf = name.lastIndexOf(' ');
    
    if (lastIndexOf == -1)
      return null;
    else
      return name.substring(0, lastIndexOf);
  }
270827
public static Long getProcessInstanceId(Command<?> command) {
		if (command instanceof ProcessInstanceIdCommand) {
			return ((ProcessInstanceIdCommand) command).getProcessInstanceId();
		} 

        return null;
		
	}
1176287
def commands_help
      longest_cmd = @commands.inject do |longest, cmd_name|
        longest.length > cmd_name.length ? longest : cmd_name
      end

      ui.output "\nCommands:"

      Hash[@command_names_and_summaries.sort].each_pair do |name, summary|
        ui.output_printf "%-#{longest_cmd.length}s      %s\n", name, summary
      end
    end
883693
public long getFirstNumericValue() {
    String val = (value != null) ? value.get(0).toString() : readValue.get(0).toString();
    if (isInteger(val)) {
      return Long.parseLong(val);
    } else {
      return 0;
    }
  }
841961
public static long firstLong(PreparedStatement stmt) throws SQLException {
		ResultSet rs = stmt.executeQuery();
		long l = rs.next() ? rs.getLong(1) : Long.MIN_VALUE;
		stmt.close();
		return l;
	}
509320
public static Pattern longest(final Pattern... patterns) {
    return new Pattern() {
      @Override
      public int match(CharSequence src, int begin, int end) {
        int r = MISMATCH;
        for (Pattern pattern : patterns) {
          int l = pattern.match(src, begin, end);
          if (l > r)
            r = l;
        }
        return r;
      }
    };
  }
665460
public T getFirst() {
        Optional<Rsp<T>> retval=values().stream().filter(rsp -> rsp.getValue() != null).findFirst();
        return retval.isPresent()? retval.get().getValue() : null;
    }