Skip to content

AndersDJohnson/accessor-SpEL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

accessor

Access objects with the Spring Expression Language. Convenient and safe access of deep fields in an object graph.

By default, uses null-safe navigation, but that and other features can be enabled or disabled.

Usage

Download the JAR and add it to your app's runtime classpath. A zipped JAR is available on the latest release, e.g. accessor-1.0.0-SNAPSHOT.jar.zip.

Simplest usage lets you do this:

  Object value = Accessor.DEFAULT.get(myObject, "some.deep.property");

instead of

Object value = myObject.getSome() != null && myObject.getSome().getDeep() != null && myObject.getSome().getDeep().getProperty();

or

Object value;
try {
  value = myObject.getSome().getDeep().getProperty();
}
catch(NullPointerException npe) {}

For more examples, see tests under "src/test/java".

Alternatives

About

Access objects with the Spring Expression Language

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages