public static double variance(Collection<?> inputList, String propertyPath) { double mean = mean(inputList, propertyPath); double temp = 0; double a; if (propertyPath.contains(".") || propertyPath.contains("[")) { String[] properties = StringScanner.splitByDelimiters(propertyPath, ".[]"); for (Object o : inputList) { a =BeanUtils.getPropertyInt(o, properties); temp += (mean-a)*(mean-a); } } else { Map<String, FieldAccess> fields = BeanUtils.getFieldsFromObject(inputList.iterator().next()); FieldAccess fieldAccess = fields.get(propertyPath); for (Object o : inputList) { a = fieldAccess.getInt(o); temp += (mean-a)*(mean-a); } } return Math.round(temp / inputList.size()); }
/** * Calculate a sum of a property from a list. * @param inputList input list * @param propertyPath to item we want to sum * @return sum */ public static long sum( Collection<?> inputList, String propertyPath ) { if (inputList.size() == 0 ) { return 0; } long sum = 0l; if (propertyPath.contains(".") || propertyPath.contains("[")) { String[] properties = StringScanner.splitByDelimiters(propertyPath, ".[]"); for (Object o : inputList) { sum+=BeanUtils.getPropertyInt(o, properties); } } else { Map<String, FieldAccess> fields = BeanUtils.getFieldsFromObject(inputList.iterator().next()); FieldAccess fieldAccess = fields.get(propertyPath); for (Object o : inputList) { sum += fieldAccess.getInt(o); } } return sum; }
public static double variance(Collection<?> inputList, String propertyPath) { double mean = mean(inputList, propertyPath); double temp = 0; double a; if (propertyPath.contains(".") || propertyPath.contains("[")) { String[] properties = StringScanner.splitByDelimiters(propertyPath, ".[]"); for (Object o : inputList) { a =BeanUtils.getPropertyInt(o, properties); temp += (mean-a)*(mean-a); } } else { Map<String, FieldAccess> fields = BeanUtils.getFieldsFromObject(inputList.iterator().next()); FieldAccess fieldAccess = fields.get(propertyPath); for (Object o : inputList) { a = fieldAccess.getInt(o); temp += (mean-a)*(mean-a); } } return Math.round(temp / inputList.size()); }
/** * Calculate a sum of a property from a list. * @param inputList input list * @param propertyPath to item we want to sum * @return sum */ public static long sum( Collection<?> inputList, String propertyPath ) { if (inputList.size() == 0 ) { return 0; } long sum = 0l; if (propertyPath.contains(".") || propertyPath.contains("[")) { String[] properties = StringScanner.splitByDelimiters(propertyPath, ".[]"); for (Object o : inputList) { sum+=BeanUtils.getPropertyInt(o, properties); } } else { Map<String, FieldAccess> fields = BeanUtils.getFieldsFromObject(inputList.iterator().next()); FieldAccess fieldAccess = fields.get(propertyPath); for (Object o : inputList) { sum += fieldAccess.getInt(o); } } return sum; }
/** * Creates a primitive list based on an input list and a property path * * @param inputList input list * @param propertyPath property path * @return primitive list */ public static IntList toIntList(Collection<?> inputList, String propertyPath) { if (inputList.size() == 0) { return new IntList(0); } IntList outputList = new IntList(inputList.size()); if (propertyPath.contains(".") || propertyPath.contains("[")) { String[] properties = StringScanner.splitByDelimiters(propertyPath, ".[]"); for (Object o : inputList) { outputList.add(BeanUtils.getPropertyInt(o, properties)); } } else { Map<String, FieldAccess> fields = BeanUtils.getFieldsFromObject(inputList.iterator().next()); FieldAccess fieldAccess = fields.get(propertyPath); for (Object o : inputList) { outputList.add(fieldAccess.getInt(o)); } } return outputList; }
public static int getPropertyInt( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toInt(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject(object); FieldAccess field = fields.get(lastProperty); if ( field.type() == Typ.intgr ) { return field.getInt( object ); } else { return Conversions.toInt(field.getValue(object)); } }
public static int getPropertyInt( final Object root, final String... properties ) { final String lastProperty = properties[ properties.length - 1 ]; if ( isDigits( lastProperty ) ) { return Conversions.toInt(getPropertyValue(root, properties)); } Object object = baseForGetProperty( root, properties ); Map<String, FieldAccess> fields = getFieldsFromObject(object); FieldAccess field = fields.get(lastProperty); if ( field.type() == Typ.intgr ) { return field.getInt( object ); } else { return Conversions.toInt(field.getValue(object)); } }
int value = fieldAccess.getInt ( parent ); if (includeDefault || include || value !=0) { serializeFieldName ( fieldName, builder );
int value = fieldAccess.getInt ( parent ); if (includeDefault || include || value !=0) { serializeFieldName ( fieldName, builder );
int value = fieldAccess.getInt ( parent ); if (value !=0) { serializeFieldName ( fieldName, builder );
int value = fieldAccess.getInt ( parent ); if (includeDefault || include || value !=0) { serializeFieldName ( fieldName, builder );
int value = fieldAccess.getInt ( parent ); if (value !=0) { serializeFieldName ( fieldName, builder );
int value = fieldAccess.getInt ( parent ); if (value !=0) { serializeFieldName ( fieldName, builder );
switch ( typeEnum ) { case INT: int value = fieldAccess.getInt ( parent ); if (value !=0) { serializeFieldName ( fieldName, builder );
switch ( typeEnum ) { case INT: int value = fieldAccess.getInt ( parent ); if (value !=0) { serializeFieldName ( fieldName, builder );
switch ( typeEnum ) { case INT: int value = fieldAccess.getInt ( parent ); if (value !=0) { serializeFieldName ( fieldName, builder );