public TypeMirror getOperatorKind ( TypeMirror leftMirror , TypeMirror rightMirror , TokenType . BinaryOperator operator ) { if ( leftMirror == null || rightMirror == null ) return null ; TypeKind leftKind = leftMirror . getKind ( ) ; TypeKind rightKind = rightMirror . getKind ( ) ; if ( isString ( leftMirror ) ) return leftMirror ; if ( isString ( rightMirror ) ) return rightMirror ; if ( either ( leftKind , rightKind , TypeKind . BOOLEAN ) ) { if ( operator != null ) { messageUtils . error ( Option . < Element > absent ( ) , "Cannot perform perform the operation '%s' with a boolean type. (%s %s %s)" , operator . toString ( ) , leftMirror , operator . toString ( ) , rightMirror ) ; } return null ; } if ( leftKind . isPrimitive ( ) && rightKind . isPrimitive ( ) ) { if ( typeUtils . isSameType ( leftMirror , rightMirror ) ) return typeUtils . getPrimitiveType ( leftKind ) ; if ( either ( leftKind , rightKind , TypeKind . DOUBLE ) ) return typeUtils . getPrimitiveType ( TypeKind . DOUBLE ) ; if ( either ( leftKind , rightKind , TypeKind . FLOAT ) ) return typeUtils . getPrimitiveType ( TypeKind . FLOAT ) ; if ( either ( leftKind , rightKind , TypeKind . LONG ) ) return typeUtils . getPrimitiveType ( TypeKind . LONG ) ; if ( either ( leftKind , rightKind , TypeKind . INT ) || either ( leftKind , rightKind , TypeKind . CHAR ) || either ( leftKind , rightKind , TypeKind . SHORT ) || either ( leftKind , rightKind , TypeKind . BYTE ) ) { return typeUtils . getPrimitiveType ( TypeKind . INT ) ; } } TypeMirror intMirror = typeUtils . getPrimitiveType ( TypeKind . INT ) ; if ( both ( assignable ( intMirror , leftMirror ) , assignable ( intMirror , rightMirror ) ) ) return intMirror ; TypeMirror longMirror = typeUtils . getPrimitiveType ( TypeKind . LONG ) ; if ( both ( assignable ( longMirror , leftMirror ) , assignable ( longMirror , rightMirror ) ) ) return longMirror ; TypeMirror floatMirror = typeUtils . getPrimitiveType ( TypeKind . FLOAT ) ; if ( both ( assignable ( floatMirror , leftMirror ) , assignable ( floatMirror , rightMirror ) ) ) return floatMirror ; TypeMirror doubleMirror = typeUtils . getPrimitiveType ( TypeKind . DOUBLE ) ; if ( both ( assignable ( doubleMirror , leftMirror ) , assignable ( doubleMirror , rightMirror ) ) ) return doubleMirror ; return null ; }
rules for this method are found here