GithubHelp home page GithubHelp logo

sheldon's Introduction

Build Status

Sheldon

A framework that detects changes and complains about them

What is Sheldon?

Sheldon is a dirty checking framework that deep compares two object graphs, detects any changes a reports (complains about) them.

A simple example:

//Just mark the Entity as Auditable
@Auditable(name = "Missy Cooper", comparatorFields = @AuditComparator({ "dnaSeq" }))
public class MissyCooper {

	//Used as the identifier of this record, hence added in @AuditComparator on the class
	private DnaSequence dnaSeq;

  //Adding @AuditField means the field is dirty checked
	@AuditField(fieldName = "Last Name", groups = "matrimony")
	private String lastName;

	//Unlikely to change hence not Audited
	private String firstName;

  //It works on component objects.
	@AuditField(fieldName = "Sibling", comparatorFields = @AuditComparator("iq"), groups = "exceptional")
	private SheldonCooper twin;
	//Because Missy keeps tabs on Sheldon and tattles to her mom
	//This could have been Person, but SheldonCooper is a singleton class with a one of a kind IQ and we are not really sure in and object of SheldonCooper passes the instanceof Person test!

	//We don't care about him, so not annotation
	private Person brother;

  //And on Iterables
	@AuditableList(groups = {"standard","mischievous"}, comparatorFields = @AuditComparator("id"))
	private List<Child> children = new ArrayList<Child>();

}

Now dirty checking is as simple as

AuditChecker checker = new AuditChecker<MissyCooper>();
//Detects all the changes
List<AuditChangeEntry> changes = checker.checkObjects(oldMissy, newMissy);
//If you only want to detect changes in the group "exceptional"
List<AuditChangeEntry> sheldonyChanges = checker.checkObjects(oldMissy, newMissy, "exceptional");

//If you only want to detect changes in the group "mischievous" and "exceptional"
List<AuditChangeEntry> mischievousChanges = checker.checkObjects(oldMissy, newMissy, "mischievous", "exceptional");

More Information

For more information please head to the wiki. A good starting point is the API Overview. If you are curious as to why the project is called Sheldon, there's a page dedicated to just that.

You can also look at the test cases to see how the API is used and the dirty checking results are used.

sheldon's People

Contributors

urvaksh avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.