Skip to content

Latest commit

 

History

History
71 lines (55 loc) · 3 KB

README.md

File metadata and controls

71 lines (55 loc) · 3 KB

object-finder CI Maven Central Javadocs

The object-finder provides utility functions to identify specific objects in complex data structures.

Object-Finder's ambition is to provide simple utility methods to find specific objects in complex data structures. The idea is that you don't want to navigate through the object over and over again. Finding various objects in a complex object often leads to multiple same looking methods and duplicated code.

The Object-Finder wants to simply your code.

Important:

The returned object is a new instance and no reference from provided root object. Changing the returned object will not affect the base object. There will be an additional API-endpoint soon.

Get object by field

      Pair<String, Object> location = Pair.of("id", "02f26e1b-e548-440d-8bfc-559d7c9fb1bd");
      Optional<CalculationPart> result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
      assertThat(result).isPresent();

Get object by nested object value

      Pair<String, Object> location = Pair.of("information/key", "SPECIAL_DISCOUNT");
      Optional<CalculationPart> result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
      assertThat(result).isPresent();

Get object by string in list

     Pair<String, Object> location = Pair.of("names[]", "specialDiscount");
     Optional<CalculationPart> result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
     assertThat(result).isPresent();

Get object by nested object value in list

     Pair<String, Object> location = Pair.of("properties[id]", "d9c40d29-e828-4c15-9519-29891496ec8e");
     Optional<CalculationPart> result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
     assertThat(result).isPresent();

Get all objects by nested object value

      Pair<String, Object> location = Pair.of("information/key", "SPECIAL_DISCOUNT");
      List<CalculationPart> result = FindObjectUtils.findAll(baseObject, location, CalculationPart.class);
      assertThat(result).hasSize(2);

Add Maven Dependency:

<dependency>
  <groupId>io.github.mrtimeey</groupId>
  <artifactId>object-finder</artifactId>
  <version>1.0.1</version>
</dependency>