Skip to content

Commit 9b80558

Browse files
authored
Merge pull request #88 from CodesAway/dev-0.11.0
Dev 0.11.0
2 parents 4404395 + e13b4ec commit 9b80558

30 files changed

+993
-176
lines changed

BEXCodeCompare/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>info.codesaway</groupId>
66
<artifactId>bex</artifactId>
7-
<version>0.10.1</version>
7+
<version>0.11.0</version>
88
<name>Be Enhanced Code Compare (BEϽC)</name>
99
<description>An enhanced code compare, utilities, and code matching</description>
1010
<properties>

BEXCodeCompare/src/main/java/info/codesaway/bex/BEXListPair.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package info.codesaway.bex;
22

33
import java.util.List;
4+
import java.util.Objects;
45
import java.util.function.Function;
56
import java.util.function.Supplier;
67

@@ -152,4 +153,24 @@ public BEXPair<E> get(final IntPair index) {
152153
public <R> BEXPair<R> map(final Function<List<E>, R> function) {
153154
return new BEXPairValue<>(function.apply(this.getLeft()), function.apply(this.getRight()));
154155
}
156+
157+
@Override
158+
public int hashCode() {
159+
return Objects.hash(this.pair);
160+
}
161+
162+
@Override
163+
public boolean equals(final Object obj) {
164+
if (this == obj) {
165+
return true;
166+
}
167+
if (obj == null) {
168+
return false;
169+
}
170+
if (this.getClass() != obj.getClass()) {
171+
return false;
172+
}
173+
BEXListPair<?> other = (BEXListPair<?>) obj;
174+
return Objects.equals(this.pair, other.pair);
175+
}
155176
}

BEXCodeCompare/src/main/java/info/codesaway/bex/BEXMapPair.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package info.codesaway.bex;
22

33
import java.util.Map;
4+
import java.util.Objects;
45
import java.util.function.Supplier;
56

67
/**
@@ -57,9 +58,10 @@ public Map<K, V> getRight() {
5758
}
5859

5960
/**
60-
* Gets the map on the specified side
61+
* Gets the map on the specified side.
62+
*
6163
* @param side the side
62-
* @return
64+
* @return the map on the specified side
6365
*/
6466
@Override
6567
public Map<K, V> get(final BEXSide side) {
@@ -76,4 +78,24 @@ public BEXPair<V> get(final K leftKey, final K rightKey) {
7678

7779
return new BEXPairValue<>(left, right);
7880
}
81+
82+
@Override
83+
public int hashCode() {
84+
return Objects.hash(this.pair);
85+
}
86+
87+
@Override
88+
public boolean equals(final Object obj) {
89+
if (this == obj) {
90+
return true;
91+
}
92+
if (obj == null) {
93+
return false;
94+
}
95+
if (this.getClass() != obj.getClass()) {
96+
return false;
97+
}
98+
BEXMapPair<?, ?> other = (BEXMapPair<?, ?>) obj;
99+
return Objects.equals(this.pair, other.pair);
100+
}
79101
}

BEXCodeCompare/src/main/java/info/codesaway/bex/BEXPair.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public default IntBEXPair mapToInt(final ToIntFunction<T> function) {
9999

100100
/**
101101
* Applies the specified BiFunction, passing {@link #getLeft()} and {@link #getRight()} as arguments
102-
102+
103103
* @param function the BiFunction to apply
104104
* @return the result of applying the BiFunction
105105
*/
@@ -109,7 +109,7 @@ public default <R> R apply(final BiFunction<T, T, R> function) {
109109

110110
/**
111111
* Applies the specified ToIntBiFunction, passing {@link #getLeft()} and {@link #getRight()} as arguments
112-
112+
113113
* @param function the ToIntBiFunction to apply
114114
* @return the result of applying the ToIntBiFunction
115115
*/
@@ -119,7 +119,7 @@ public default int applyAsInt(final ToIntBiFunction<T, T> function) {
119119

120120
/**
121121
* Evaluates the specified BiPredicate, passing {@link #getLeft()} and {@link #getRight()} as arguments
122-
122+
123123
* @param predicate the BiPredicate to apply
124124
* @return <code>true</code> if the predicate matches when applying the arugments; otherwise, <code>false</code>
125125
*/

BEXCodeCompare/src/main/java/info/codesaway/bex/BEXPairValue.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ public BEXPairValue(final Supplier<T> supplier) {
3535
}
3636

3737
/**
38-
* Creates a new BEXPair using the results of applying the specified function for both {@link BEXSide#LEFT} and {@link BEXSide#RIGHT}
39-
* @param <T>
38+
* Creates a new BEXPair using the results of applying the specified function for both {@link BEXSide#LEFT} and {@link BEXSide#RIGHT}.
39+
*
40+
* @param <T> the generic type
4041
* @param function the function to apply
41-
* @return
42+
* @return the BEXPairValue
4243
* @since 0.4
4344
*/
4445
// Changed from constructor to static method due to ambiguity between this and constructor accepting a Supplier

BEXCodeCompare/src/main/java/info/codesaway/bex/ImmutableIntRangeMap.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static info.codesaway.bex.util.BEXUtilities.checkArgument;
44
import static info.codesaway.bex.util.BEXUtilities.entry;
55

6+
import java.util.AbstractMap;
67
import java.util.ArrayList;
78
import java.util.Collection;
89
import java.util.Collections;
@@ -31,7 +32,9 @@ public final class ImmutableIntRangeMap<V> {
3132

3233
private static final Comparator<IntRange> KEY_COMPARATOR = Comparator.comparingInt(IntRange::getStart);
3334

34-
/** Returns an empty immutable range map. */
35+
/**
36+
* Returns an empty immutable range map.
37+
*/
3538
@SuppressWarnings("unchecked")
3639
public static <V> ImmutableIntRangeMap<V> of() {
3740
return (ImmutableIntRangeMap<V>) EMPTY;
@@ -42,7 +45,9 @@ private ImmutableIntRangeMap(final List<IntRange> ranges, final List<V> values)
4245
this.values = values;
4346
}
4447

45-
/** Returns a new builder for an immutable range map. */
48+
/**
49+
* Returns a new builder for an immutable range map.
50+
*/
4651
public static <V> Builder<V> builder() {
4752
return new Builder<>();
4853
}
@@ -276,17 +281,12 @@ public Entry<IntRange, V> next() {
276281
}
277282
}
278283

279-
private final class MapOfRanges implements Map<IntRange, V> {
284+
private final class MapOfRanges extends AbstractMap<IntRange, V> {
280285
@Override
281286
public int size() {
282287
return ImmutableIntRangeMap.this.ranges.size();
283288
}
284289

285-
@Override
286-
public boolean isEmpty() {
287-
return this.size() == 0;
288-
}
289-
290290
@Override
291291
public boolean containsKey(final Object key) {
292292
return key instanceof IntRange && ImmutableIntRangeMap.this.getIndexForRange((IntRange) key) >= 0;

BEXCodeCompare/src/main/java/info/codesaway/bex/diff/AbstractDiffAlgorithm.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1212

13+
/**
14+
*
15+
*/
1316
public abstract class AbstractDiffAlgorithm implements DiffAlgorithm {
1417
private final List<DiffLine> leftLines;
1518
private final List<DiffLine> rightLines;
@@ -34,10 +37,19 @@ protected AbstractDiffAlgorithm(final List<DiffLine> leftLines, final List<DiffL
3437
this.normalizationFunction = firstNonNull(normalizationFunction, DiffHelper.NO_NORMALIZATION_FUNCTION);
3538
}
3639

40+
/**
41+
* Gets the left lines
42+
* @return the left lines
43+
*/
3744
public List<DiffLine> getLeftLines() {
3845
return this.leftLines;
3946
}
4047

48+
/**
49+
* Gets the right lines.
50+
*
51+
* @return the right lines
52+
*/
4153
public List<DiffLine> getRightLines() {
4254
return this.rightLines;
4355
}
@@ -52,8 +64,8 @@ public BiFunction<String, String, DiffNormalizedText> getNormalizationFunction()
5264
/**
5365
* Gets the text from the specified line in {@link #getLeftLines()}
5466
*
55-
* @param index
56-
* @return
67+
* @param index the line number
68+
* @return the left text on the specified line number
5769
*/
5870
public String getLeftText(final int index) {
5971
return this.getLeftLines().get(index).getText();
@@ -62,8 +74,8 @@ public String getLeftText(final int index) {
6274
/**
6375
* Gets the text from the specified line in {@link #getRightLines()}
6476
*
65-
* @param index
66-
* @return
77+
* @param index the line number
78+
* @return the right text on the specified line
6779
*/
6880
public String getRightText(final int index) {
6981
return this.getRightLines().get(index).getText();

BEXCodeCompare/src/main/java/info/codesaway/bex/diff/DiffEdit.java

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,38 @@ public Stream<DiffEdit> stream() {
8080
}
8181

8282
/**
83-
* Gets the first side which has data (left or right)
83+
* Gets the first side which has data (left or right).
84+
*
85+
* @return the first side
8486
*/
8587
public BEXSide getFirstSide() {
8688
return this.hasLeftLine() ? LEFT : RIGHT;
8789
}
8890

91+
/**
92+
* Gets the line.
93+
*
94+
* @param side the side
95+
* @return the optional line
96+
*/
8997
public Optional<DiffLine> getLine(final BEXSide side) {
9098
return side == LEFT ? this.getLeftLine() : this.getRightLine();
9199
}
92100

101+
/**
102+
* Gets the left line.
103+
*
104+
* @return the left line
105+
*/
93106
public Optional<DiffLine> getLeftLine() {
94107
return this.leftLine;
95108
}
96109

110+
/**
111+
* Gets the right line.
112+
*
113+
* @return the right line
114+
*/
97115
public Optional<DiffLine> getRightLine() {
98116
return this.rightLine;
99117
}
@@ -110,35 +128,54 @@ public boolean hasLine(final BEXSide side) {
110128

111129
/**
112130
* Indicates if has left line
131+
*
132+
* @return <code>true</code> if has left line
113133
*/
114134
public boolean hasLeftLine() {
115135
return this.getLeftLine().isPresent();
116136
}
117137

118138
/**
119139
* Indicates if has right line
140+
*
141+
* @return <code>true</code> if has right line
120142
*/
121143
public boolean hasRightLine() {
122144
return this.getRightLine().isPresent();
123145
}
124146

147+
/**
148+
* Gets the text.
149+
*
150+
* @return the text
151+
*/
125152
public String getText() {
126153
return this.getText(this.getFirstSide());
127154
}
128155

156+
/**
157+
* Gets the text.
158+
*
159+
* @param side the side
160+
* @return the text
161+
*/
129162
public String getText(final BEXSide side) {
130163
return this.getLine(side).orElse(ABSENT_LINE).getText();
131164
}
132165

133166
/**
134-
* Gets the text for the left line
167+
* Gets the text for the left line.
168+
*
169+
* @return the left text
135170
*/
136171
public String getLeftText() {
137172
return this.getText(LEFT);
138173
}
139174

140175
/**
141-
* Gets the text for the right line
176+
* Gets the text for the right line.
177+
*
178+
* @return the right text
142179
*/
143180
public String getRightText() {
144181
return this.getText(RIGHT);
@@ -183,8 +220,9 @@ public int getRightLineNumber() {
183220
}
184221

185222
/**
186-
* Gets the line number (as a String) for the specified side
223+
* Gets the line number (as a String) for the specified side.
187224
*
225+
* @param side the side
188226
* @return the line number (or the empty string if there is no line for the specified side)
189227
*/
190228
public String getLineNumberString(final BEXSide side) {

BEXCodeCompare/src/main/java/info/codesaway/bex/matching/BEXGroupMatchSetting.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package info.codesaway.bex.matching;
22

3-
import java.util.HashMap;
4-
import java.util.Map;
3+
import java.util.concurrent.ConcurrentHashMap;
54

65
/**
76
* BEX group match settings
@@ -10,7 +9,7 @@
109
* Methods which turn on or off flags return a different settings object (from cache when possible) with the specified settings changed</p>
1110
*/
1211
final class BEXGroupMatchSetting {
13-
private static final Map<Integer, BEXGroupMatchSetting> CACHE = new HashMap<>();
12+
private static final ConcurrentHashMap<Integer, BEXGroupMatchSetting> CACHE = new ConcurrentHashMap<>();
1413

1514
private final int flags;
1615

BEXCodeCompare/src/main/java/info/codesaway/bex/matching/BEXMatchResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public default int end(final String group) {
8989

9090
/**
9191
*
92-
* @param group
92+
* @param group the group
9393
* @return
9494
* @throws IllegalStateException
9595
* If no match has yet been attempted,

0 commit comments

Comments
 (0)