Class UpdateListenerAdapter

  • All Implemented Interfaces:
    UpdateListener

    public class UpdateListenerAdapter
    extends java.lang.Object
    implements UpdateListener
    Dummy implementation of UpdateListener to simplify selective implementation. Also used when no listener configured.
    Since:
    17.08.2021
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void backupCreated​(java.io.File backup)
      Called after backup file creation (only if required).
      void configured​(UpdateConfig config)
      Called just before start to provide access to configuration actually used by merger (catching configuration errors).
      void currentConfigParsed​(CmtTree tree, StructTree struct)
      Parsed current configuration with two parsers (preserving comments and snakeyaml).
      void merged​(CmtTree result)
      Called just after the merge, but before final validation.
      void updateConfigParsed​(CmtTree tree, StructTree struct)
      Parsed new configuration with two parsers (preserving comments and snakeyaml).
      void validated​(StructTree result)
      Called after result validation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UpdateListenerAdapter

        public UpdateListenerAdapter()
    • Method Detail

      • configured

        public void configured​(UpdateConfig config)
        Description copied from interface: UpdateListener
        Called just before start to provide access to configuration actually used by merger (catching configuration errors).
        Specified by:
        configured in interface UpdateListener
        Parameters:
        config - configuration instance
      • updateConfigParsed

        public void updateConfigParsed​(CmtTree tree,
                                       StructTree struct)
        Description copied from interface: UpdateListener
        Parsed new configuration with two parsers (preserving comments and snakeyaml). At this point trees were validated to be equal (merger self-control mechanism).

        Environment variables already applied.

        Passed structure tree would be used later for the final result validation, so be careful with modifications.

        If you going to modify tree then modify both trees accordingly (otherwise final validation would fail)

        Specified by:
        updateConfigParsed in interface UpdateListener
        Parameters:
        tree - comments tree
        struct - structure tree
        See Also:
        for creating new comment nodes, for creating new struct nodes
      • currentConfigParsed

        public void currentConfigParsed​(CmtTree tree,
                                        StructTree struct)
        Description copied from interface: UpdateListener
        Parsed current configuration with two parsers (preserving comments and snakeyaml). At this point trees were validated to be equal (merger self-control mechanism).

        Configured deletions already applied.

        Method would not be called if current configuration does not exist.

        Passed structure tree would be used later for the final result validation, so be careful with modifications.

        NOTE: The same CmtTree instance used for updates and would be written to file after merge.

        If you going to modify tree then modify both trees accordingly (otherwise final validation would fail)

        Specified by:
        currentConfigParsed in interface UpdateListener
        Parameters:
        tree - comments tree
        struct - structure tree
        See Also:
        for creating new comment nodes, for creating new struct nodes
      • merged

        public void merged​(CmtTree result)
        Description copied from interface: UpdateListener
        Called just after the merge, but before final validation. Provided structure would be written to file after validation.

        NOTE: validation would detect modifications and deny entire update. If you want to manually correct the resulted tree then disable result validation (it would still read the resulted file to make sure it's semantically correct, but would not compare with old/new files).

        Specified by:
        merged in interface UpdateListener
        Parameters:
        result - merge result
        See Also:
        for creating new comment nodes
      • validated

        public void validated​(StructTree result)
        Description copied from interface: UpdateListener
        Called after result validation. Not called if validation disabled.

        At this point merged file was already saved. Passed model is a read of just merged file for validation. Any changes to this model will not take any effect. Method may be used for additional validations.

        Specified by:
        validated in interface UpdateListener
        Parameters:
        result - parsed merged file (with snakeyaml)
      • backupCreated

        public void backupCreated​(java.io.File backup)
        Description copied from interface: UpdateListener
        Called after backup file creation (only if required).
        Specified by:
        backupCreated in interface UpdateListener
        Parameters:
        backup - created backup file for current configuration