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
      java.lang.String devPrint()
      Prints the Changes in a technical style.
      Change get​(int index)  
      <C extends Change>
      java.util.List<C>
      getChangesByType​(java.lang.Class<C> type)
      Returns a subset of Changes with a given type
      java.util.List<PropertyChange> getPropertyChanges​(java.lang.String propertyName)  
      java.util.List<ChangesByCommit> groupByCommit()
      Returns changes grouped by commits.
      java.util.List<ChangesByObject> groupByObject()
      Changes grouped by entities.
      java.lang.String prettyPrint()
      Prints the list of Changes to a nicely formatted String.
      Can be used on GUI to show Changes to your users.
      int size()  
      java.lang.String toString()
      Delegates to devPrint().
      See prettyPrint()
      • 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()
        Returns changes grouped by commits.
        When formatting a changelog, usually you need to group changes by commits and then by objects.

        A simple changelog, like devPrint(), can be printed by this code:

         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
      • getPropertyChanges

        public java.util.List<PropertyChange> getPropertyChanges​(java.lang.String propertyName)
      • 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)
        Returns a subset of Changes with a given type
      • toString

        public java.lang.String toString()
        Delegates to devPrint().
        See prettyPrint()
        Overrides:
        toString in class java.util.AbstractCollection<Change>
      • prettyPrint

        public final java.lang.String prettyPrint()
        Prints the list of Changes to a nicely formatted String.
        Can be used on GUI to show Changes to your users.

        Example:

         Changes:
         Commit 2.00 done by author at 14 Mar 2021, 12:37:37 :
         * changes on Employee/Frodo :
           - 'lastPromotionDate' = '14.37.2021 12:37'
           - 'performance' map changes :
              · entry ['1' : 'bb'] -> ['1' : 'aa']
              · entry ['2' : 'bb'] added
              · entry ['3' : 'aa'] removed
           - 'position' = 'Hero'
           - 'postalAddress.city' = 'Shire'
           - 'primaryAddress.city' changed: 'Shire' -> 'Mordor'
           - 'primaryAddress.street' = 'Some Street'
           - 'salary' changed: '10000' -> '12000'
           - 'skills' collection changes :
              · 'agile coaching' added
           - 'subordinates' collection changes :
              0. 'Employee/Sam' added
         * new object: Employee/Sam
           - 'name' = 'Sam'
           - 'salary' = '10000'
         Commit 1.00 done by author at 14 Mar 2021, 12:37:37 :
         * new object: Employee/Frodo
           - 'name' = 'Frodo'
           - 'performance' map changes :
              · entry ['1' : 'bb'] added
              · entry ['3' : 'aa'] added
           - 'primaryAddress.city' = 'Shire'
           - 'salary' = '10000'
           - 'skills' collection changes :
              · 'management' added
         
      • devPrint

        public java.lang.String devPrint()
        Prints the Changes in a technical style.
        Useful for development and debugging.

        You can use the implementation of this method as a template to create your own changelog
        (if prettyPrint() is not ok for you).

        Example:

         Changes (18):
         commit 2.00
           changes on Employee/Frodo :
           - ValueChange{ property: 'city', left:'Shire',  right:'Mordor' }
           - ValueChange{ property: 'street', left:'',  right:'Some Street' }
           - ValueChange{ property: 'position', left:'',  right:'Hero' }
           - ValueChange{ property: 'salary', left:'10000',  right:'12000' }
           - ListChange{ property: 'subordinates', elementChanges:1 }
           - SetChange{ property: 'skills', elementChanges:1 }
           - MapChange{ property: 'performance', entryChanges:3 }
           - ValueChange{ property: 'lastPromotionDate', left:'',  right:'14 Mar 2021, 12:58:06+0100' }
           - InitialValueChange{ property: 'city', left:'',  right:'Shire' }
           changes on Employee/Sam :
           - NewObject{ new object: Employee/Sam }
           - InitialValueChange{ property: 'name', left:'',  right:'Sam' }
           - InitialValueChange{ property: 'salary', left:'',  right:'10000' }
         commit 1.00
           changes on Employee/Frodo :
           - InitialValueChange{ property: 'city', left:'',  right:'Shire' }
           - NewObject{ new object: Employee/Frodo }
           - InitialValueChange{ property: 'name', left:'',  right:'Frodo' }
           - InitialValueChange{ property: 'salary', left:'',  right:'10000' }
           - SetChange{ property: 'skills', elementChanges:1 }
           - MapChange{ property: 'performance', entryChanges:2 }