Constructs a new MistakeManager and initialises the MistakeCategoryMap. Does NOT initialise the #uiManager (this has to be done manually).
Private
categoryA MistakeCategoryMap containing all Mistakes available by their categories (CategoryNames).
Private
mistakesAn Array containing all Mistakes (in all MistakeCategorys), sorted by their Mistake#orderIDs.
Private
uiAdds a given Mistake
and brings it into the correct position by calling sortMistakes.
true
if the Mistake was added successfully
the Mistake to add to #categoryMistakes and #mistakes
Permanently removes a given Mistake by calling deleteMistakeByID with mistake#fields#id.
true
if the Mistake was deleted successfully
IllegalArgumentError if the given Mistake is not in the mistakes array at all.
Deletes a Mistake with a given id from its MistakeCategory and the overall mistakes Array. Adjusts the IDs of the remaining Mistakes in the MistakeCategory such that they are still consecutive and still start at 1.
true
if the Mistake was deleted successfully
IllegalArgumentError if the given ID does not match the ID pattern or if no Mistake with the given ID exists in the given CategoryNames.
the Mistake#id of the Mistake to be deleted
Generates a YAML file containing the Mistakes, including the user's changes, and lets the user save it.
true
if the file was generated successfully
Returns a new draft Mistake with the given category and a new GrammleID, by calling #generateGrammleID, and without any other fields set.
This method is supposed to be called for creating a new Mistake in the UI.
Info: The UID is optional and will only be set if it is valid.
the new Mistake
the category to generate the Mistake for
Optional
uid: stringthe UID to set for the Mistake (optional)
Returns the highest ID number in the given category, starting at 1. Returns 0 if no mistakes are in the category.
the ID number
the category to search
Returns the given Mistake's index in the array of the CategoryNames. Partly written by GitHub Copilot.
Zero-based index of the Mistake in the CategoryNames's array.
Return value -1
means “not found”.
the Mistake in question
the CategoryNames to search
Returns the index of the Mistake with the given GrammleID in the array of the CategoryNames.
Zero-based index of the Mistake in the CategoryNames's array. Return value -1
means “not found”.
the CategoryNames to search
Returns the index of the Mistake with the given ID in the array of the CategoryNames.
Zero-based index of the Mistake in the CategoryNames's array. Return value -1
means “not found”.
IllegalArgumentError if the given ID does not match the ID pattern.
the ID of the Mistake in question
the CategoryNames to search
Returns the index of the Mistake with the given UID in #categoryMistakes.
Zero-based index of the Mistake in the #categoryMistakes array. Return value -1
means “not found”.
IllegalArgumentError if the given UID is not a valid 32-bit MD5 hash.
the UID of the Mistake in question
the CategoryNames to search
Returns a deep clone of the first Mistake matching the given ID.
A deep copy of the Mistake with the given ID
or false
if no Mistake could be found.
IllegalArgumentError if the given ID does not match the ID pattern.
the ID of the Mistake to find
Returns the first Mistake matching the given UID.
A deep copy of the Mistake with the given UID or false
if no Mistake could be found.
IllegalArgumentError if the given UID is not a valid 32-bit MD5 hash.
the UID of the Mistake to find
Private
initConstructs a new MistakeCategoryMap with all CategoryNames as keys and new MistakeCategorys as corresponding values. All MistakeCategories are being initialised.
the new MistakeCategoryMap
Private
mergeUpdates the overall #mistakes Array by merging all Mistakes from the #categoryMistakes map.
true
if the Mistakes were merged successfully, false
otherwise
Private
mistakesMoves a given Mistake inside the mistakes array in the given MoveDirection.
true
if the Mistake was moved successfully, false
if the Mistake could not be moved in the given MoveDirection
IllegalArgumentError if the given Mistake is not in the mistakes array at all.
the Mistake to move
the MoveDirection to move the Mistake in
Private
recreateCreates a new #categoryMistakes map from scratch by adding all Mistakes from #mistakes to their respective categories.
true
if the #categoryMistakes map was re-created successfully
Sets deep copies of given Mistakes as the new Mistakes, updates the #MistakeCategoryMap
accordingly, sorts all Mistakes and returns true
if the operation was successful.
true
if the operation was successful
IllegalArgumentError if the given Mistakes are invalid
Private
sortSorts the Mistakes in #mistakes alphabetically by their Mistake#id and recreates the #MistakeCategoryMap by calling #mergeCategories().
true
if the Mistakes were sorted successfully, false
otherwise
Swaps two Mistakes in the mistakes array by calling swapMistakesInCategoryByIndex.
true
if the Mistakes were swapped successfully
IllegalArgumentError if the given Mistakes are not in the same MistakeCategory.
Swaps two Mistakes in the mistakes array by their indices in a given category.
true
if the Mistakes were swapped successfully
IllegalArgumentError if the given CategoryNames is not present in Mistake#kategorien.
the CategoryNames to swap the Mistakes in
the index of the first Mistake to swap
the index of the second Mistake to swap
the EditMode that was used to update the Mistake
Private
validateGenerated using TypeDoc
Stores and manages all Mistakes. Start by using addMistake to add a Mistake to a CategoryNames.