| 1 |
--- |
| 2 |
layout: docs |
| 3 |
title: Why should I use OWNER? |
| 4 |
prev_section: features |
| 5 |
next_section: faq |
| 6 |
permalink: /docs/why/ |
| 7 |
--- |
| 8 |
|
| 9 |
The reason why OWNER was written is because the code dealing with the configuration is frequently repetitive, |
| 10 |
redundant, it's made of boring and ugly static classes, singletons, long list of methods just doing conversion from a |
| 11 |
string property to a named method returning a Java primitive or a basic Java object. |
| 12 |
|
| 13 |
I don't want to provide negative examples, but just have a look around on how java.util.Properties is used. |
| 14 |
The main reason why I wrote this library is to get rid of that ugly code. |
| 15 |
|
| 16 |
OWNER solves the problem providing an interface object that |
| 17 |
|
| 18 |
- it's easy to mock (see [Mockito](http://mockito.org)), easy to pass to other objects (via dependency injection). |
| 19 |
- declaratively maps your configuration without any redundancy. |
| 20 |
- can easily expand your loading logic in order to have multiple configuration files, multiple level of |
| 21 |
overriding (global configuration, user-level, defaults, etc). |
| 22 |
- doesn't need to have an actual properties file backing your configuration, if you use `@DefaultValue`. |
| 23 |
- provides a lot of features, like hot reloading, variables expansion, etc. |
| 24 |
- leaves you free to do everything you are already doing with java.util.Properties. |
| 25 |
- does support a super powerful [type conversion]({{ site.url }}/docs/type-conversion/), which includes arrays, |
| 26 |
collections, many standard Java objects, and even the possibility to plug your own conversion logic. |
| 27 |
- it does not bring any transitive dependency to your project, so no conflicting jars, no dependency issues. |
| 28 |
- it is developed to work with any reasonably recent JDK. Each commit on OWNER repository is |
| 29 |
[tested](https://travis-ci.org/lviggiano/owner) on Oracle JDK and Open JDK from version 7 to version 9. |
| 30 |
|
| 31 |
...and more than everything, it's not an ugly, rigid, boring, repetitive list of methods doing all the same thing. |