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

ObjectHelper's after/before/between enhancements

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.18.1, 2.19.0
    • camel-core
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: