All Projects → SQiShER → Java Object Diff

SQiShER / Java Object Diff

Licence: apache-2.0
Library to diff and merge Java objects with ease

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Java Object Diff

Coding Interview Gym
leetcode.com , algoexpert.io solutions in python and swift
Stars: ✭ 451 (-37.79%)
Mutual labels:  tree-structure
Changedetection
Automatically track websites changes on Android in background.
Stars: ✭ 563 (-22.34%)
Mutual labels:  diff
Xcdiff
A tool which helps you diff xcodeproj files.
Stars: ✭ 641 (-11.59%)
Mutual labels:  diff
Hdiffpatch
a C\C++ library and command-line tools for Diff & Patch between binary files or directories(folder); cross-platform; run fast; create small delta/differential; support large files and limit memory requires when diff & patch.
Stars: ✭ 459 (-36.69%)
Mutual labels:  diff
Patch Package
Fix broken node modules instantly 🏃🏽‍♀️💨
Stars: ✭ 6,062 (+736.14%)
Mutual labels:  diff
Diffabledatasources
💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
Stars: ✭ 601 (-17.1%)
Mutual labels:  diff
Treeview
An android tree structure view with high performance and rich features
Stars: ✭ 429 (-40.83%)
Mutual labels:  tree-structure
Java Diff Utils
Diff Utils library is an OpenSource library for performing the comparison / diff operations between texts or some kind of data: computing diffs, applying patches, generating unified diffs or parsing them, generating diff output for easy future displaying (like side-by-side view) and so on.
Stars: ✭ 670 (-7.59%)
Mutual labels:  diff
Datasources
💾 🔜📱 Type-safe data-driven CollectionView, TableView Framework. (We can also use ASCollectionNode)
Stars: ✭ 553 (-23.72%)
Mutual labels:  diff
Sirix
SirixDB is a temporal, evolutionary database system, which uses an accumulate only approach. It keeps the full history of each resource. Every commit stores a space-efficient snapshot through structural sharing. It is log-structured and never overwrites data. SirixDB uses a novel page-level versioning approach called sliding snapshot.
Stars: ✭ 638 (-12%)
Mutual labels:  diff
Ete
Python package for building, comparing, annotating, manipulating and visualising trees. It provides a comprehensive API and a collection of command line tools, including utilities to work with the NCBI taxonomy tree.
Stars: ✭ 506 (-30.21%)
Mutual labels:  tree-structure
Deep Object Diff
Deep diffs two objects, including nested structures of arrays and objects, and returns the difference. ❄️
Stars: ✭ 515 (-28.97%)
Mutual labels:  diff
Qlibc
qLibc is a simple and yet powerful C library providing generic data structures and algorithms
Stars: ✭ 614 (-15.31%)
Mutual labels:  tree-structure
Bosket
Collection of tree view components for front-end frameworks. 🌳
Stars: ✭ 457 (-36.97%)
Mutual labels:  tree-structure
React Diff Viewer
A simple and beautiful text diff viewer component made with Diff and React.
Stars: ✭ 642 (-11.45%)
Mutual labels:  diff
Diff Match Patch
Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.
Stars: ✭ 4,910 (+577.24%)
Mutual labels:  diff
Daff
align and compare tables
Stars: ✭ 598 (-17.52%)
Mutual labels:  diff
Django Treebeard
Efficient tree implementations for Django
Stars: ✭ 689 (-4.97%)
Mutual labels:  tree-structure
Diffdom
A diff for DOM elements, as client-side JavaScript code. Gets all modifications, insertions and removals between two DOM fragments.
Stars: ✭ 660 (-8.97%)
Mutual labels:  diff
Nanomorph
🚅 - Hyper fast diffing algorithm for real DOM nodes
Stars: ✭ 621 (-14.34%)
Mutual labels:  diff

Introduction

java-object-diff is a simple, yet powerful library to find differences between Java objects. It takes two objects and generates a tree structure that represents any differences between the objects and their children. This tree can then be traversed to extract more information or apply changes to the underlying data structures.

Build Status Coverage Status Download Documentation Status

Features

  • Works out-of-the-box with with almost any kind of object and arbitrarily deep nesting
  • Finds the differences between two objects
  • Returns the differences in shape of an easily traversable tree structure
  • Tells you everything there is to know about the detected changes
  • Provides read and write access to the underlying objects, allowing you not only to extract the changed values but even to apply the diff as a patch
  • Requires no changes to your existing classes (in most cases)
  • Provides a very flexible configuration API to tailor everything to your needs
  • Tiny, straightforward, yet very powerful API
  • Detects and handles circular references in the object graph
  • No runtime dependencies except for SLF4J
  • Compatible with Java 1.5 and above

Support this Project

If you like this project, there are a few things you can do to show your support:

But most importantly: don't ever hesitate to ask me for help, if you're having trouble getting this library to work. The only way to make it better is by hearing about your use-cases and pushing the limits!

Getting Started

To learn how to use Java Object Diff have a look at the Getting Started Guide.

Using with Maven

<dependency>
    <groupId>de.danielbechler</groupId>
    <artifactId>java-object-diff</artifactId>
    <version>0.95</version>
</dependency>

Using with Gradle

compile 'de.danielbechler:java-object-diff:0.95'

Documentation

The documentation can be found over at ReadTheDocs.

Caveats

  • Introspection of values other than primitives and collection types is curently done via standard JavaBean introspection, which requires your objects to provide getters and setters for their properties. However, you don't need to provide setters, if you don't need write access to the properties (e.g. you don't want to apply the diff as a patch.)

    If this does not work for you, don't worry: you can easily write your own introspectors and just plug them in via configuration API.

  • Ordered lists are currently not properly supported (they are just treated as Sets). While this is something I definitely want to add before version 1.0 comes out, its a pretty big task and will be very time consuming. So far there have been quite a few people who needed this feature, but not as many as I imagined. So your call to action: if you need to diff and/or merge collection types like ArrayList, perhaps even with multiple occurence of the same value, please let me know. The more I'm aware of the demand and about the use-cases, the more likely it is, that I start working on it.

Why would you need this?

Sometimes you need to figure out, how one version of an object differs from another one. One of the simplest solutions that'll cross your mind is most certainly to use reflection to scan the object for fields or getters and use them to compare the values of the different object instances. In many cases this is a perfectly valid strategy and the way to go. After all, we want to keep things simple, don't we?

However, there are some cases that can increase the complexity dramatically. What if you need to find differences in collections or maps? What if you have to deal with nested objects that also need to be compared on a per-property basis? Or even worse: what if you need to merge such objects?

You suddenly realize that you need to scan the objects recursively, figure out which collection items have been added, removed or changed; find a way to return your results in a way that allows you to easily access the information you are looking for and provide accessors to apply changes.

While all this isn't exactly rocket science, it is complex enough to add quite a lot of extra code to your project. Code that needs to be tested and maintained. Since the best code is the code you didn't write, this library aims to help you with all things related to diffing and merging of Java objects by providing a robust foundation and a simple, yet powerful API.

This library will hide all the complexities of deep object comparison behind one line of code:

DiffNode root = ObjectDifferBuilder.buildDefault().compare(workingObject, baseObject);

This generates a tree structure of the given object type and lets you traverse its nodes via visitors. Each node represents one property (or collection item) of the underlying object and tells you exactly if and how the value differs from the base version. It also provides accessors to read, write and remove the value from or to any given instance. This way, all you need to worry about is how to treat changes and not how to find them.

This library has been battle-tested in a rather big project of mine, where I use it to generate activity streams, resolve database update conflics, display change logs and limit the scope of entity updates to only a subset of properties, based on the context or user permissions. It didn't let me down so far and I hope it can help you too!

Contribute

You discovered a bug or have an idea for a new feature? Great, why don't you send me a Pull Request so everyone can benefit from it? To help you getting started, here is a brief guide with everyting you need to know to get involved!


Thanks to JetBrains for supporting this project with a free open source license for their amazing IDE IntelliJ IDEA.

IntelliJ IDEA

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].