Idea is to create annotation for a method that receives List of String and validate the size of the list. example @CheckParams(size = 2) public void setParams(List<String> params){ //it could helps to avoid dublicate of checking params size. }