Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrtimeey/object-finder
Library for finding objects in complex data structures
https://github.com/mrtimeey/object-finder
Last synced: 11 days ago
JSON representation
Library for finding objects in complex data structures
- Host: GitHub
- URL: https://github.com/mrtimeey/object-finder
- Owner: MrTimeey
- License: mit
- Created: 2023-11-10T21:10:29.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-08-01T19:31:50.000Z (3 months ago)
- Last Synced: 2024-10-10T18:44:07.962Z (28 days ago)
- Language: Java
- Size: 46.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# object-finder [![CI](https://github.com/MrTimeey/object-finder/actions/workflows/mvn-build.yml/badge.svg?branch=main)](https://github.com/MrTimeey/object-finder/actions/workflows/mvn-build.yml?query=branch%3Amain) [![Maven Central](https://img.shields.io/maven-central/v/io.github.mrtimeey/object-finder.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22io.github.mrtimeey%22%20AND%20a:%22object-finder%22) [![Javadocs](http://www.javadoc.io/badge/io.github.mrtimeey/object-finder.svg)](http://www.javadoc.io/doc/io.github.mrtimeey/object-finder)
The object-finder provides utility functions to identify specific objects in complex data structures.
* [Object-Finder's goals](#goals)
* [TL;DR](#tldr)
* [Longer example](./exampleUseCase.md)
* [Quickstart](#quickstart)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
```java
Pair location = Pair.of("id", "02f26e1b-e548-440d-8bfc-559d7c9fb1bd");
Optional result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
assertThat(result).isPresent();
```### Get object by nested object value
```java
Pair location = Pair.of("information/key", "SPECIAL_DISCOUNT");
Optional result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
assertThat(result).isPresent();
```### Get object by string in list
```java
Pair location = Pair.of("names[]", "specialDiscount");
Optional result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
assertThat(result).isPresent();
```### Get object by nested object value in list
```java
Pair location = Pair.of("properties[id]", "d9c40d29-e828-4c15-9519-29891496ec8e");
Optional result = FindObjectUtils.find(baseObject, location, CalculationPart.class);
assertThat(result).isPresent();
```### Get all objects by nested object value
```java
Pair location = Pair.of("information/key", "SPECIAL_DISCOUNT");
List result = FindObjectUtils.findAll(baseObject, location, CalculationPart.class);
assertThat(result).hasSize(2);
```Add Maven Dependency:
```xmlio.github.mrtimeey
object-finder
1.0.1```