Skip to content

Commit

Permalink
added better description of exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszbudnik committed Feb 15, 2015
1 parent e8befe1 commit f5f887d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ String isoCode = elvis(person, p -> p.getAddress().getCountry().getISOCode());

The first argument to ```elvis``` method is the root object and the second one is the function to be evaluated.

If either ```person``` is null or ```getAddress()``` or ```getCountry()``` returns ```null```, the whole call returns ```null```.
If either ```person``` is null or ```getAddress()``` or ```getCountry()``` returns null, the whole call returns null.

No NPE is thrown.

Java 8 lambdas have some problems with functions throwing exceptions. If the last method in a chain throws checked exception you need to use ```wrappedFunction``` like this:
No ```NullPointerException``` is thrown. All other exceptions are preserved. However, Java 8 lambdas have some problems with functions throwing checked exceptions. If your methods throw checked exception you need to use ```wrappedFunction``` like this:

```
import static com.github.lukaszbudnik.jelvis.Elvis.elvis;
Expand All @@ -31,6 +29,8 @@ Person person = new Person();
String line2 = elvis(person, wrappedFunction(p -> p.getAddress().getLine2()));
```

See examples for more information.

# Examples

See `src/test/java` for unit tests and examples.
Expand Down

0 comments on commit f5f887d

Please sign in to comment.