Java tutorial
//package com.java2s; import java.util.Collection; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; public class Main { public static int countTrue(String propertyName, Collection<?> collection) { int count = 0; for (Object o : collection) { BeanWrapper bw = new BeanWrapperImpl(o); Boolean propertyValue = (Boolean) bw.getPropertyValue(propertyName); if (Boolean.TRUE.equals(propertyValue)) { count++; } } return count; } }