@Nullable
    private AttributeType.DataType<?> validateAndGetTargetDataType(GraqlCompute.Statistics.Value query) {
        AttributeType.DataType<?> dataType = null;
        for (Type type : targetTypes(query)) {
            // check if the selected type is a attribute type
            if (!type.isAttributeType()) throw GraqlQueryException.mustBeAttributeType(type.label());
            AttributeType<?> attributeType = type.asAttributeType();
            if (dataType == null) {
                // check if the attribute type has data-type LONG or DOUBLE
                dataType = attributeType.dataType();
                if (!dataType.equals(AttributeType.DataType.LONG) && !dataType.equals(AttributeType.DataType.DOUBLE)) {
                    throw GraqlQueryException.attributeMustBeANumber(dataType, attributeType.label());
                }
            } else {
                // check if all the attribute types have the same data-type
                if (!dataType.equals(attributeType.dataType())) {
                    throw GraqlQueryException.attributesWithDifferentDataTypes(query.of());
                }
            }
        }
        return dataType;
    }
@ Nullable private AttributeType . DataType < ? > validateAndGetTargetDataType ( GraqlCompute . Statistics . Value query ) { AttributeType . DataType < ? > dataType = null ; for ( Type type : targetTypes ( query ) ) { if ( ! type . isAttributeType ( ) ) throw GraqlQueryException . mustBeAttributeType ( type . label ( ) ) ; AttributeType < ? > attributeType = type . asAttributeType ( ) ; if ( dataType == null ) { dataType = attributeType . dataType ( ) ; if ( ! dataType . equals ( AttributeType . DataType . LONG ) && ! dataType . equals ( AttributeType . DataType . DOUBLE ) ) { throw GraqlQueryException . attributeMustBeANumber ( dataType , attributeType . label ( ) ) ; } } else { if ( ! dataType . equals ( attributeType . dataType ( ) ) ) { throw GraqlQueryException . attributesWithDifferentDataTypes ( query . of ( ) ) ; } } } return dataType ; }
Helper method to validate that the target types are of one data type, and get that data type

@return the DataType of the target types