Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-5839

Public API: Separate DataContext conversion concern from `as()` instance method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • None
    • Core Engine
    • 3
    • False
    • False
    • 2021 Week 40-42 (from Oct 4), 2021 Week 46-48 (from Nov 15), 2021 Week 49-51 (from Dec 6th)

      Currently DataContext conversion is done through an as() method. The `as()` method internally delegates to an ObjectMapper.

      DataContext and Castable both provide an {as()}} method. DefaultCastable provide a default implementation.

      However, this makes it necessary for user classes to implement the `as()` method (usually through the DefaultCastable interface).

      The as() instance method is really only for esthetic reasons – or, in other words, for lack of extension methods in Java.

      A static method such as Convert.from(obj).to(target) would be just as good.

      Thus:

      • we remove the as() method from DataContext
      • we rename DefaultCastable to DefaultConversion
      • we remove the implements clause from DefaultConversion
      • we delete the Castable class.
      • we create the class/methods for Convert.from(obj).to(target)
      • optional: DefaultConversion#as(Class<T> t) invokes Convert.from(this).to(t)

      System classes will always implement DefaultConversion to provide the as() utility method. Users can opt-in whether they want to implement it or use the static version.

              Unassigned Unassigned
              evacchi Edoardo Vacchi (Inactive)
              Marian Macik Marian Macik
              Marian Macik Marian Macik
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: