title: Method accepting two different types as parameter
body: <p>I am writing a method that should accept as its parameter an object of one of two types which do not share a parent type other than Object. For example, the types are Dreams and Garlic. You can do both <code>dreams.crush()</code> and <code>garlic.crush()</code>. I want to have a method <code>utterlyDestroy(parameter)</code>, that would accept as its parameter both Dreams and Garlic.</p>
  
  <pre><code>utterlyDestroy(parameter) {
      parameter.crush()
  }
  </code></pre>
  
  <p>Both Garlic and dreams are a part of some library, so having them implement an interface ICrushable (so that I could write <code>utterlyDestroy(ICrushable parameter)</code> ) is not an option.</p>
  
  <p>My method body is quite long so overloading it would mean duplicating code. Ugly.
  I am sure I could use reflection and do some class hacking. Ugly.</p>
  
  <p>I tried using generics but apparently I cannot write something like</p>
  
  <pre><code>utterlyDestroy(&lt;T instanceof Dreams || T instanceof Garlic&gt; parameter)
  </code></pre>
  
  <p>Is it possible to typecast Garlic to Dreams?</p>
  
  <pre><code>utterlyDestroy(Object parameter) {
      ((Dreams)parameter).crush()
  }
  </code></pre>
  
  <p>This would still be ugly though. What are my other options and what is the preferred method of dealing with the situation?</p>