Class TextFileBasedViolationStore
java.lang.Object
com.tngtech.archunit.library.freeze.TextFileBasedViolationStore
- All Implemented Interfaces:
ViolationStore
@PublicAPI(usage=ACCESS)
public final class TextFileBasedViolationStore
extends Object
implements ViolationStore
A text file based implementation of a
This
It will keep an index of all stored rules as well as a mapping to the individual rule violation files in the same folder.
By default, the layout within the configured store folder will look like:
This
ViolationStore.This
ViolationStore will store the violations of every single FreezingArchRule in a dedicated file.It will keep an index of all stored rules as well as a mapping to the individual rule violation files in the same folder.
By default, the layout within the configured store folder will look like:
storeFolder
|-- stored.rules (the index file of all stored rules)
|-- 6fc2fd04-b3ab-44e0-8f78-215c66f2174a (a rule violation file named randomly by UUID and referenced from stored.rules)
|-- 2186b43a-c24c-417d-bd96-547e2dfdba1c (another rule violation file)
|-- ... (more rule violation files for every rule that has been stored so far)
To adjust the strategy how the individual rule violation files are named use the constructor
TextFileBasedViolationStore(RuleViolationFileNameStrategy).This
ViolationStore can be configured through the following properties:
default.path=... # string: the path of the folder where violation files will be stored
default.allowStoreCreation=... # boolean: whether to allow creating a new index file
default.allowStoreUpdate=... # boolean: whether to allow updating any store file
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAllows to adjust the rule violation file names ofTextFileBasedViolationStoreNested classes/interfaces inherited from interface com.tngtech.archunit.library.freeze.ViolationStore
ViolationStore.Delegate -
Constructor Summary
ConstructorsConstructorDescriptionCreates a standardTextFileBasedViolationStorethat names rule violation files by randomUUIDsTextFileBasedViolationStore(TextFileBasedViolationStore.RuleViolationFileNameStrategy ruleViolationFileNameStrategy) Creates aTextFileBasedViolationStorewith a custom strategy for rule violation file naming -
Method Summary
Modifier and TypeMethodDescriptionbooleangetViolations(ArchRule rule) voidinitialize(Properties properties) Provides custom initialization with properties derived from "archunit.properties" by considering the sub properties offreeze.store.voidProvides a way to initially store or later update violations of anArchRule.
-
Constructor Details
-
TextFileBasedViolationStore
public TextFileBasedViolationStore()Creates a standardTextFileBasedViolationStorethat names rule violation files by randomUUIDs -
TextFileBasedViolationStore
public TextFileBasedViolationStore(TextFileBasedViolationStore.RuleViolationFileNameStrategy ruleViolationFileNameStrategy) Creates aTextFileBasedViolationStorewith a custom strategy for rule violation file naming- Parameters:
ruleViolationFileNameStrategy- controls how the rule violation file name is derived from the rule description
-
-
Method Details
-
initialize
Description copied from interface:ViolationStoreProvides custom initialization with properties derived from "archunit.properties" by considering the sub properties offreeze.store.
If "archunit.properties" contains, e.g.,
then this method will be called with properties containingfreeze.store.propOne=valueOne freeze.store.propTwo=valueTwopropOne=valueOne propTwo=valueTwo- Specified by:
initializein interfaceViolationStore- Parameters:
properties- The properties derived from the "archunit.properties" prefixfreeze.store.
-
contains
- Specified by:
containsin interfaceViolationStore- Parameters:
rule- AnArchRule- Returns:
- true, if and only if this
ViolationStorecontains stored violations for the passedArchRule
-
save
Description copied from interface:ViolationStoreProvides a way to initially store or later update violations of anArchRule. If there are violations currently stored for the passed rule, those violations will be completely overwritten.- Specified by:
savein interfaceViolationStore- Parameters:
rule- AnArchRuleto store violations forviolations- A list of lines of violations of anArchRule
-
getViolations
- Specified by:
getViolationsin interfaceViolationStore- Parameters:
rule- AnArchRule- Returns:
- The lines of violations currently stored for the passed
ArchRule
-