static-import

What is a good use case for static import of methods?

Just got a review comment that my static import of the method was not a good idea. The static import was of a method from a DA class, which has mostly static methods. So in middle of the business logic I had a da activity that apparently seemed to belong to the current class: static import some.package.DA.*; class BusinessObject { voi...

Overloading static imports

In a test class, I’d like to provide my own overload of assertEquals with some special logic not relying on Object.equals. Unfortunately, that doesn’t work because as soon as I declare my assertEquals method locally, Java doesn’t find the static import from org.junit.Assert.* any more. Is there a way around this? I.e. is there a way to ...

Can I do a static import of a private subclass?

I have an enum which is private, not to be exposed outside of the class. Is there anyway I can do a static import of that type, so that I don't have to type the enum type each time? Or is there a better way to write this? Example: package kip.test; import static kip.test.Test.MyEnum.*; //compile error public class Test { private s...