I have what seems like a daunting task of the Java library.
I need to write adapter / helper class to work with JTable, which has some additional features, if JTableis JXTable. But I do not want to add a run-time dependency on swingx-core-1.6.2.jar if my application does not actually use JXTable (in this case it already requires the presence of a jing SwingX file in the classpath)
How can I separate my code from this? I don’t even know how I can test JXTable; if I try to use instanceof JXTableas a test, it means that my code already has an unconditional runtime dependency on JXTable.
I wrote Java libraries before they have “extra” runtime dependencies: if I have this in my library:
package com.foobar.foolib;
import com.whizbang.BloatwareThingy;
public class SuperObject
{
}
and SuperObject- the only class that uses whizbang.jar, then while my final application is not using SuperObject, then there is no runtime dependency on whizbang.jar; if my final application really wants to use SuperObject, then it needs to include whizbang.jar in the classpath. Optional from an application point of view. It works great.
How to write a method to verify that a given JTable is an instance of JXTable without requiring a dependency on the SwingX jar file if the application uses only JTable?