Michael
Michael

Reputation: 42050

How to parse expressions to access POJO properties?

Suppose I am checking POJO properties in my unit tests as

assertNotNull(pojo1.getX().getY().getZ());
assertEquals(pojo2.getA().getB().getStr(), "foo")
assertEquals(pojo2.getC().getD().getNum(), 100)

Now I have to read the properties and their values from a text file, which contains:

pojo1.x.y.z
pojo2.a.b.str = foo
pojo2.c.d.num = 100

What is the best way to convert those text expression into the java code above?

Upvotes: 0

Views: 92

Answers (1)

Aravind Yarram
Aravind Yarram

Reputation: 80186

Use OGNL or MVEL for this.

Upvotes: 1

Related Questions