Simple java library to manage RUT as value object.
- Immutable value object
- Parse from string value
- Validate if check digit is correct
- Implements serializable interface
- Implements comparable interfaces, list of
rut
is sortable. - Implements
hashcode
andequals,
the rut object could be used as a key on a Hashmap or HashSet collections. - Implements
toString
method, return format "123.123-1" - Published on maven central
This library is only compatible with Java version 8 or newer
Already published on maven central
Gradle
compile "com.saburto:ruts:1.0.1"
Maven
<dependency>
<groupId>com.saburto</groupId>
<artifactId>ruts</artifactId>
<version>1.0.1</version>
</dependency>
Code example:
Rut rut = Rut.parse("124.123-4"); // parse from String
new Rut(1234, "k"); // constructor by integer and string
rut.isValid(); // returns `true` if check digit is correct
rut.toString() // returns "124.123-4"
Map<Rut, Foo> map = new HashMap<>() // could be used as key on hashmap/hashset
Set<Rut> set = new HashSet<>(); // rut implements `hashcode` and `equals`