I get a list that has several types of HTMLElements. I need a NameValuePair list, with name and value of each object. So I have this function that gets the list:
private List getValoresPost(List parametros){
List<NameValuePair> param = new ArrayList<>();
parametros.forEach(parametro -> {
String type = parametro.getClass().getSimpleName();
param.add(new NameValuePair(((HtmlHiddenInput) parametro).getNameAttribute(), ((HtmlHiddenInput) parametro).getValueAttribute()
));
});
return param;
}
As I said, each object is of a different type, which I thought: get the type name of that object, and pass in the cast parameter. In place of (HtmlHiddenInput) I put the type but as object. How?