Umesh Awasthi
Umesh Awasthi

Reputation: 23587

Strange issue with Apache common collection

I am not sure what might be the cause of this issue but i am facing it since morning and seems like i am doing something wrong or i have done something wrong with my Eclipse IDE

i have included Apache commom collection is my project using maven as follow

<dependency>
   <groupId>commons-collections</groupId>
   <artifactId>commons-collections</artifactId>
   <version>3.2.1</version>
</dependency>

Depedency is getting included correctly, but when i am trying to use following method of collection util

MapUtils.isEmpty(java.util.Map map) 
or
MapUtils.isNotEmpty(java.util.Map map) 

They are not being shown in the editor and only method i can see under MapUtil is

invertMap(java.util.Map map) 

i check the import statement in Eclipse and its

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;

Not sure where things are going wrong as i have used above utility method number of times, do any one have any clue

Upvotes: 5

Views: 15155

Answers (2)

Caesar Ralf
Caesar Ralf

Reputation: 2233

Are you sure it's 3.2.1 you are using? Check from where the import is comming from. You maybe having some conflict, because one of your libs is importing another version of apache.commons.

Try importing "org.apache.commons.collections.MapUtils" and see if there's still a problem.

Upvotes: 3

Your import is correct. CollectionUtils ( http://commons.apache.org/collections/apidocs/index.html?org/apache/commons/collections/CollectionUtils.html ) has methods

CollectionUtils.isEmpty(java.util.Map map) 
CollectionUtils.isNotEmpty(java.util.Map map) 

You are just looking int the wrong class MapUtils.

Upvotes: 0

Related Questions