title: What pattern should I use with transformers?
body: <p>I have my transformer abstract class:</p>
  
  <pre><code>public abstract class Transformer&lt;T, S&gt; {
  
      public abstract S transform(T object);
  
      public abstract T revert(S object);
  
      public List&lt;S&gt; transformArray(Collection&lt;T&gt; iterable) {
          try {
              List&lt;S&gt; transformed = new ArrayList&lt;S&gt;();
              Iterator&lt;T&gt; iterator = iterable.iterator();
              while (iterator.hasNext()) {
                  T element = iterator.next();
                  transformed.add(this.transform(element));
              }
              return transformed;
          } catch (Exception e) {
              e.printStackTrace();
              return null;
          }
  
      }
  
      public List&lt;T&gt; revertArray(Collection&lt;S&gt; iterable) {
          try {
              List&lt;T&gt; transformed = new ArrayList&lt;&gt;();
              Iterator&lt;S&gt; iterator = iterable.iterator();
              while (iterator.hasNext()) {
                  S element = iterator.next();
                  transformed.add(this.revert(element));
              }
              return transformed;
          } catch (Exception e) {
              e.printStackTrace();
              return null;
          }
      }
  
  }
  </code></pre>
  
  <p>And I want to have my DTOTransformer, which is like</p>
  
  <pre><code>public abstract class DTOTransformer&lt;DTOREQ, OTHER, DTORES&gt; {
  
      Transformer&lt;DTOREQ, OTHER&gt; forwardTransformer;
      Transformer&lt;OTHER, DTORES&gt; backwardTransformer;
  
      // Not overriding, since isn't and hasn't a transformer
      public OTHER transform(DTOREQ object) {
           return forwardTransformer.transform(object);
      }
  
      // Not overriding, since isn't and hasn't a transformer
      public DTORES revert(OTHER object) {
           return backwardTransformer.transform(object);
      }
  
  }
  </code></pre>
  
  <p>The problem is that I have not actually any implementation for backwardTransformer and forwardTransformer's transform() method. What I want is that when I create a subclass from DTOTransformer, for an example, ClientDTOTransformer then I have to implement the transform and revert methods (which are not the same of the methods that Transformer's class offers since I have a "triangular" transformation). </p>
  
  <p>I have already tried using the adapter pattern but I couldn't find the way to implement it. </p>
  
  <p>Do you know how I could do this? Or if you know a better way to do this, I am open to suggestions.</p>