This is a little math expression validation with java, basically evaluated if a math expression is correct according of the parenthesis or not, I tried to used basic stuff validations to do this.
result
Now if you change your math expression for example something like this
this will be return false because at the end are a parenthesis that never opened
hope it helps for something and feel free to comment