FEST-Reflect 1.2: Fluent Interface for Java Reflection

by Алекс Руис on November 30, 2009

We are proud to announce that FEST-Reflect 1.2 is out!

FEST-Reflect is a Java library that provides a fluent interface that simplifies the usage of Java Reflection and JavaBeans Introspection, resulting in improved readability and type safety. It supports class loading, access to static inner classes constructors, methods and fields, and more!

Example:

Person person = constructor().withParameterTypes(String.class)
                             .in(Person.class)
                             .newInstance("Yoda");
 
method("setName").withParameterTypes(String.class)
                 .in(person)
                 .invoke("Luke");
 
field("name").ofType(String.class)
             .in(person)
             .set("Anakin");
 
List<String> powers = field("powers").ofType(new TypeRef<List<String>>() {})
                                     .in(jedi)
                                     .get();

Release notes

Bug

  • [FEST-68] – FEST-Reflect is catching my RuntimeException while it should not! (issue 310.) Thanks to Francis.ANDRE.
  • [FEST-257] – FEST-Reflect should throw exception if static inner class is not found.

Improvement

  • [FEST-256] – Replace constructor calls with fail-fast static factory methods.

New Feature

  • [FEST-235] – Add API to reflect bean properties. Thanks to Jean-Francois Poilpret.

    Example:

    // equivalent to calling "getName()"
    String name = property("name").ofType(String.class)
                                  .in(person)
                                  .get();

FEST-Swing can be downloaded here (file fest-reflect-1.2.zip.) FEST requires Java SE 5.0 or later.

Links

Feedback is always appreciated :)

{ 2 comments… read them below or add one }

Karam November 30, 2009 at 4:36 pm

The project looks interesting.

In you example, “Add API to reflect bean properties”, the comment says you are setting a property however the code is for getting a property.

Reply

Alex Ruiz November 30, 2009 at 5:10 pm

Thanks Karam! It is fixed now :)

Reply

Leave a Comment

Previous post:

Next post: