How to declare method signature in an interface to accept an unknown type variable?
<p>I'm creating several different classes, each to interact with a different API.  I made an interface for each class to inherit from, but one of the methods in the interface can take in several different data types depending on which API is being implemented.  Is it possible to define an unknown type for that method to take in?</p>

<p>For now I'm just declaring it as an <code>Object</code> and casting it within the implementation.</p>

<p>Interface:</p>

<pre><code>public interface UDSession {

    public void authenticate(String user) throws UDException;

    public void linkAccount(Object authInfo) throws UDException;

}
</code></pre>

<p>Method implementations (just the signature and first line):</p>

<p>Dropbox:</p>

<pre><code>    public void linkAccount(Object authInfo) throws UDException {
        WebAuthSession.WebAuthInfo info = (WebAuthSession.WebAuthInfo) authInfo;
}
</code></pre>

<p>Google:</p>

<pre><code>   public void linkAccount(Object authInfo) throws UDException {
                GoogleOAuthParameters info = (GoogleOAuthParameters) authInfo;
        }
</code></pre>

<p>I also tried defining it in the interface as: <code>Class&lt;?&gt;</code> and defining it in the method signature implementation as: <code>Class&lt;WebAuthSession.WebAuthInfo&gt;</code>.  But this didn't work.</p>

<p>There's got to be a better way to do this than using <code>Object</code> type parameters.  Any ideas?</p>

<p>Thanks.</p>
