Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-10390

ObjectHelper's after/before/between enhancements

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.18.1, 2.19.0
    • Component/s: camel-core
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      I've sometime had the need to find a string after a separator, lookup
      an object based on the result value and then use it to process
      something, like:

      String after = ObjectHelper.after(key, ":");
      if (after != null) {
      MyStuff s = cache.get(after)
      if (s != null)

      { s.doSomething(exchange) }

      }

      So I wonder whether it makes sense to add a 'fluent' variant to these
      functions to impement such pattern, like:

      <T> Optional<T> after(String value, String delimiter,
      Function<String, T> function)

      The we could do something like:

      ObjectHelper.after(key, ":", cache::get).ifPresent(s ->
      s.doSomething(exchange));

        Attachments

          Activity

            People

            • Assignee:
              lb Luca Burgazzoli
              Reporter:
              lb Luca Burgazzoli
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: