Class Changes

    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Change get​(int index)  
      <C extends Change>
      java.util.List<C>
      getChangesByType​(java.lang.Class<C> type)  
      java.util.List<ChangesByCommit> groupByCommit()
      Changes grouped by commits.
      java.util.List<ChangesByObject> groupByObject()
      Changes grouped by entities.
      java.lang.String prettyPrint()
      Prints the nicely formatted list of Changes.
      int size()  
      java.lang.String toString()  
      • Methods inherited from class java.util.AbstractList

        add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Method Detail

      • groupByCommit

        public java.util.List<ChangesByCommit> groupByCommit()
        Changes grouped by commits.
        When formatting a changelog, usually you need to group changes by commits and then by objects.

        For example, this changelog:
         commit 2.0
           changes on Employee/Frodo :
           - ValueChange{ 'salary' changed from '10000' to '11000' }
           - ListChange{ 'subordinates' collection changes :
           0. 'Employee/Sam' added }
           changes on Employee/Sam :
           - ValueChange{ 'name' changed from '' to 'Sam' }
           - ValueChange{ 'salary' changed from '0' to '2000' }
           - ReferenceChange{ 'boss' changed from '' to 'Employee/Frodo' }
           - NewObject{ new object: Employee/Sam }
         commit 1.0
           changes on Employee/Frodo :
           - ValueChange{ 'name' changed from '' to 'Frodo' }
           - ValueChange{ 'salary' changed from '0' to '10000' }
           - NewObject{ new object: Employee/Frodo }
         
        is printed by this code:
         Changes changes = javers.findChanges(QueryBuilder.byClass(Employee.class)
                                 .withNewObjectChanges().build());
        
         changes.groupByCommit().forEach(byCommit -> {
           System.out.println("commit " + byCommit.getCommit().getId());
           byCommit.groupByObject().forEach(byObject -> {
             System.out.println("  changes on " + byObject.getGlobalId().value() + " : ");
             byObject.get().forEach(change -> {
               System.out.println("  - " + change);
             });
           });
         });
         
        Since:
        3.9
        See Also:
        http://javers.org/documentation/repository-examples/#change-log
      • get

        public Change get​(int index)
        Specified by:
        get in interface java.util.List<Change>
        Specified by:
        get in class java.util.AbstractList<Change>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<Change>
        Specified by:
        size in interface java.util.List<Change>
        Specified by:
        size in class java.util.AbstractCollection<Change>
      • getChangesByType

        public <C extends Change> java.util.List<C> getChangesByType​(java.lang.Class<C> type)
      • prettyPrint

        public final java.lang.String prettyPrint()
        Prints the nicely formatted list of Changes. Alias to toString().
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<Change>