17
17
*/
18
18
public final class PomModifications extends TreeSet <PomModifications .Modification > {
19
19
20
+ /**
21
+ * Returns an instance of the Final class configure with an iterable of all loaded POM file modifications.
22
+ *
23
+ * @see org.technologybrewery.baton.util.pom.PomModifications.Final
24
+ */
20
25
public Final finalizeMods () {
21
26
return new Final (iterator ());
22
27
}
23
28
29
+ /**
30
+ * A class to iteratively apply a series of POM file modifications.
31
+ *
32
+ * @see org.technologybrewery.baton.util.pom.PomModifications.Modification
33
+ */
24
34
public static class Final {
25
35
private Iterator <Modification > iterator ;
26
36
private Modification next ;
27
37
38
+ /**
39
+ * Constructor that initializes a series of POM file modifications passed in as an Iterator of the
40
+ * internally defined Modification class.
41
+ *
42
+ * @param iterator A given Iterator of the type Modification.
43
+ * @see org.technologybrewery.baton.util.pom.PomModifications.Modification
44
+ */
28
45
private Final (Iterator <Modification > iterator ) {
29
46
this .iterator = iterator ;
30
47
next = iterator .next ();
@@ -38,11 +55,11 @@ public boolean appliesTo(int lineNumber) {
38
55
/**
39
56
* Applies the next modification to the input reader, writing the result to the output writer.
40
57
*
41
- * @param in the input reader
42
- * @param out the output writer
43
- * @param line the current line of the input reader
44
- * @return the line number of `in` after the modification has been applied (changes iff the input reader was advanced)
45
- * @throws IOException if an I/O error occurs
58
+ * @param in the input reader.
59
+ * @param out the output writer.
60
+ * @param line the current line of the input reader.
61
+ * @return the line number of `in` after the modification has been applied (changes iff the input reader was advanced).
62
+ * @throws IOException if an I/O error occurs.
46
63
*/
47
64
public int apply (BufferedReader in , Writer out , String line ) throws IOException {
48
65
int newInputLine = next .apply (in , out , line );
@@ -55,9 +72,19 @@ public int apply(BufferedReader in, Writer out, String line) throws IOException
55
72
}
56
73
}
57
74
75
+ /**
76
+ * The abstract class by which all POM file modifications inherit from.
77
+ */
58
78
public static abstract class Modification implements Comparable <Modification > {
59
79
private final InputLocation start ;
60
80
81
+ /**
82
+ * The constructor accepts an InputLocation type representing the line and column of the file
83
+ * where modifications will start being applied.
84
+ *
85
+ * @param start the location to begin modifying the content.
86
+ * @see org.apache.maven.model.InputLocation
87
+ */
61
88
public Modification (InputLocation start ) {
62
89
this .start = start ;
63
90
}
@@ -85,6 +112,13 @@ public int compareTo(Modification o) {
85
112
public static class Deletion extends Modification {
86
113
private final InputLocation end ;
87
114
115
+ /**
116
+ * Constructor to delete content between the given start and end parameters.
117
+ *
118
+ * @param start the location to begin deleting POM file content (inclusive).
119
+ * @param end the location to stop deleting POM file content (exclusive).
120
+ * @see org.apache.maven.model.InputLocation
121
+ */
88
122
public Deletion (InputLocation start , InputLocation end ) {
89
123
super (start );
90
124
this .end = end ;
@@ -125,9 +159,12 @@ public static class Insertion extends Modification {
125
159
private final int currentIndent ;
126
160
127
161
/**
128
- * @param start the location to insert the content (will insert before the existing content on that line)
129
- * @param currentIndent the indent level of the current content on the line
130
- * @param contentProducer a function that produces the content to insert, given a one-level indent string
162
+ * Constructor to insert content before the given start existing content on the given start index.
163
+ *
164
+ * @param start the location to insert the content (before the existing content on that line).
165
+ * @param currentIndent the indent level of the current content on the line.
166
+ * @param contentProducer a function that produces the content to insert, given a one-level indent string.
167
+ * @see org.apache.maven.model.InputLocation
131
168
*/
132
169
public Insertion (InputLocation start , int currentIndent , Function <String ,String > contentProducer ) {
133
170
super (start );
@@ -156,9 +193,9 @@ public static class Replacement extends Modification {
156
193
/**
157
194
* Constructor for replacing content within a single line.
158
195
*
159
- * @param start the location to insert the new content
160
- * @param end the location to skip to, existing content between start and end will be deleted
161
- * @param content the new content
196
+ * @param start the location to insert the new content.
197
+ * @param end the location to skip to, existing content between start and end will be deleted.
198
+ * @param content the new content.
162
199
*/
163
200
public Replacement (InputLocation start , InputLocation end , String content ) {
164
201
this (start , end , 0 , l -> content );
@@ -167,10 +204,10 @@ public Replacement(InputLocation start, InputLocation end, String content) {
167
204
/**
168
205
* Constructor for multi-line replacements.
169
206
*
170
- * @param start the location to insert the new content
171
- * @param end the location to skip to, existing content between start and end will be deleted
172
- * @param indentLvl the indent level of the current content on the line
173
- * @param contentProducer a function that produces the content to insert, given a one-level indent string
207
+ * @param start the location to insert the new content.
208
+ * @param end the location to skip to, existing content between start and end will be deleted.
209
+ * @param indentLvl the indent level of the current content on the line.
210
+ * @param contentProducer a function that produces the content to insert, given a one-level indent string.
174
211
*/
175
212
public Replacement (InputLocation start , InputLocation end , int indentLvl , Function <String ,String > contentProducer ) {
176
213
super (start );
0 commit comments