java - Refactoring usage of a util method -


in 1 of our projects, there has been utils defined follows:

// check if collection null or empty public static boolean isnullorempty(collection collection) {     return collection == null || collection.isempty(); } 

but of api usages of form:

list<string> samplelist = null; // process samplelist if(!utils.isnullorempty(samplelist)) {     // action } 

where end checking inverse.


there's proposal add method:

public static boolean isnotnullorempty(collection collection) {     return !isnullorempty(collection); } 

which replace such usages of api shared above

if(utils.isnotnullorempty(samplelist)) {     // action } 

imp: wouldn't want alter usages utils.isnullorempty not accompanied !.

q1. 1 task here refactor existing usages once we've added isnotnullorempty utility. there ide implementation can such refactoring (using intellij)

q2. in terms of implementation, usefulness can derived change? remember intellij's inspection results reporting in control flow issues suggesting define such method in order avoid inversion.

note - expecting (1) can safely done @ ide level.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -