@ 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 ; }
Helper method to validate that the target types are of one data type and get that data type