Convert String to Code

前端 未结 18 1096
轮回少年
轮回少年 2020-11-22 09:27

I want to know if there is any way to convert a String to Java compilable code.

I have a comparative expression saved in a database field. I want to re

18条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 10:04

    You'd be much better off mapping your database condition info to an object and either implementing an equals method on it that you can use with BeanPropertyValueEqualsPredicate from the apache commons beanutils or implement Comparable instead. This should do what you're after without all the magic compiler nastiness or security issues of converting strings to code.

提交回复
热议问题