I have a class that builds a HttpResponse initializer. in one of the methods that should return the BasicNameValuePair
I have to check if there is a entry in the list with key or name specified by String "name".
public List<BasicNameValuePair> getPostPairs() {
if(mPostPairs == null || mPostPairs.size() < 1) {
throw new NullPointerException(TAG + ": PostPairs is null or has no items in it!");
}
//there is no hasName() or hasKey() method :(
if(!mPostPairs.hasName("action")) {
throw new IllegalArgumentException(TAG + ": There is no 'action' defined in the collections");
}
return mPostPairs;
}
How to do this? if it is not possible with BasicNameValuePair, what would be the alternative? subclassing and adding the method?
I need to use this for a HttpPost, which its setEntity only accepts this type:
public UrlEncodedFormEntity (List<? extends NameValuePair> parameters)