1. Project Clover database Wed Nov 12 2025 05:07:35 UTC
  2. Package guru.mikelue.foxglove.annotation

File GenDataInspector.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
10
6
2
116
54
6
0.6
1.67
3
1

Classes

Class Line # Actions
GenDataInspector 10 2 0% 1 0
1.0100%
GenDataInspectorImpl 73 8 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 22 tests. .

Source view

1    package guru.mikelue.foxglove.annotation;
2   
3    import org.apache.commons.lang3.Validate;
4   
5    import guru.mikelue.foxglove.annotation.GenData.FallbackDataGeneratorProvider;
6   
7    /**
8    * A convenient interface to process objects defined by {@link GenData}.
9    */
 
10    public interface GenDataInspector {
11    /**
12    * Creates an instance of {@link GenDataInspector}.
13    *
14    * @param genData The annotation instance of {@link GenData}
15    *
16    * @return The instance of {@link GenDataInspector}
17    */
 
18  45 toggle public static GenDataInspector of(GenData genData)
19    {
20  45 Validate.isTrue(
21    genData.generatorName().isEmpty() ||
22    genData.generator() == FallbackDataGeneratorProvider.class,
23    "Only one of 'generatorName()' and 'generator()' should be used"
24    );
25   
26  45 return new GenDataInspectorImpl(genData);
27    }
28   
29    /**
30    * Returns the annotation instance of {@link GenData}.
31    *
32    * @return The annotation instance of {@link GenData}
33    */
34    GenData genData();
35   
36    /**
37    * Returns the number of table facets defined in {@link GenData}.
38    *
39    * @return The number of table facets
40    */
41    int numberOfTableFacets();
42   
43    /**
44    * Indicates whether the default data generator is used.
45    *
46    * <p>
47    * The default data generator is used when both of the following conditions are met:
48    * <ul>
49    * <li>The {@link GenData#generatorName()} is not set (empty string),</li>
50    * <li>The {@link GenData#generator()} is set to {@link FallbackDataGeneratorProvider}.</li>
51    * </ul>
52    *
53    * @return true if the default data generator is used; false otherwise
54    */
55    boolean useDefaultDataGenerator();
56    /**
57    * Indicates whether the default table facets are used.
58    *
59    * <p>
60    * The default table facets are used when all of the following conditions are met:
61    *
62    * <ul>
63    * <li>The {@link GenData#facetsNames()} is not set (empty array),</li>
64    * <li>The {@link GenData#value()} is not set (empty array),</li>
65    * <li>The {@link GenData#facets()} is not set (empty array).</li>
66    * </ul>
67    *
68    * @return true if the default table facets are used; false otherwise
69    */
70    boolean useDefaultTableFacets();
71    }
72   
 
73    class GenDataInspectorImpl implements GenDataInspector {
74    private final GenData genData;
75    private final boolean useDefaultDataGenerator;
76    private final boolean useDefaultTableFacets;
77    private final int numberOfTableFacets;
78   
 
79  45 toggle GenDataInspectorImpl(GenData genData)
80    {
81  45 this.genData = genData;
82   
83  45 this.useDefaultDataGenerator = genData.generatorName().isEmpty() &&
84    genData.generator() == FallbackDataGeneratorProvider.class;
85   
86  45 this.numberOfTableFacets = genData.value().length +
87    genData.facets().length +
88    genData.facetsNames().length;
89   
90  45 this.useDefaultTableFacets = numberOfTableFacets == 0;
91    }
92   
 
93  52 toggle @Override
94    public GenData genData()
95    {
96  52 return this.genData;
97    }
98   
 
99  34 toggle @Override
100    public boolean useDefaultDataGenerator()
101    {
102  34 return this.useDefaultDataGenerator;
103    }
104   
 
105  34 toggle @Override
106    public boolean useDefaultTableFacets()
107    {
108  34 return this.useDefaultTableFacets;
109    }
110   
 
111  26 toggle @Override
112    public int numberOfTableFacets()
113    {
114  26 return this.numberOfTableFacets;
115    }
116    }