Skip to content

Commit c580b61

Browse files
committed
Merge pull request iluwatar#380 from DevFactory/release/Type-parameter-names-should-comply-with-a-naming-convention-fix-1
squid:S00119 - Type parameter names should comply with a naming conve…
2 parents 9714fe0 + d3689b2 commit c580b61

File tree

5 files changed

+101
-101
lines changed

5 files changed

+101
-101
lines changed

fluentinterface/src/main/java/com/iluwatar/fluentinterface/app/App.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,14 @@ private static Predicate<? super Integer> positives() {
114114
return integer -> integer > 0;
115115
}
116116

117-
private static <TYPE> void prettyPrint(String prefix, Iterable<TYPE> iterable) {
117+
private static <E> void prettyPrint(String prefix, Iterable<E> iterable) {
118118
prettyPrint(", ", prefix, iterable);
119119
}
120120

121-
private static <TYPE> void prettyPrint(String delimiter, String prefix,
122-
Iterable<TYPE> iterable) {
121+
private static <E> void prettyPrint(String delimiter, String prefix,
122+
Iterable<E> iterable) {
123123
StringJoiner joiner = new StringJoiner(delimiter, prefix, ".");
124-
Iterator<TYPE> iterator = iterable.iterator();
124+
Iterator<E> iterator = iterable.iterator();
125125
while (iterator.hasNext()) {
126126
joiner.add(iterator.next().toString());
127127
}

fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
* the fluent interface design pattern. This interface defines common operations, but doesn't aim to
3535
* be complete. It was inspired by Guava's com.google.common.collect.FluentIterable.
3636
*
37-
* @param <TYPE> is the class of objects the iterable contains
37+
* @param <E> is the class of objects the iterable contains
3838
*/
39-
public interface FluentIterable<TYPE> extends Iterable<TYPE> {
39+
public interface FluentIterable<E> extends Iterable<E> {
4040

4141
/**
4242
* Filters the contents of Iterable using the given predicate, leaving only the ones which satisfy
@@ -46,63 +46,63 @@ public interface FluentIterable<TYPE> extends Iterable<TYPE> {
4646
* tested object is removed by the iterator.
4747
* @return a filtered FluentIterable
4848
*/
49-
FluentIterable<TYPE> filter(Predicate<? super TYPE> predicate);
49+
FluentIterable<E> filter(Predicate<? super E> predicate);
5050

5151
/**
5252
* Returns an Optional containing the first element of this iterable if present, else returns
5353
* Optional.empty().
5454
*
5555
* @return the first element after the iteration is evaluated
5656
*/
57-
Optional<TYPE> first();
57+
Optional<E> first();
5858

5959
/**
6060
* Evaluates the iteration and leaves only the count first elements.
6161
*
6262
* @return the first count elements as an Iterable
6363
*/
64-
FluentIterable<TYPE> first(int count);
64+
FluentIterable<E> first(int count);
6565

6666
/**
6767
* Evaluates the iteration and returns the last element. This is a terminating operation.
6868
*
6969
* @return the last element after the iteration is evaluated
7070
*/
71-
Optional<TYPE> last();
71+
Optional<E> last();
7272

7373
/**
7474
* Evaluates the iteration and leaves only the count last elements.
7575
*
7676
* @return the last counts elements as an Iterable
7777
*/
78-
FluentIterable<TYPE> last(int count);
78+
FluentIterable<E> last(int count);
7979

8080
/**
81-
* Transforms this FluentIterable into a new one containing objects of the type NEW_TYPE.
81+
* Transforms this FluentIterable into a new one containing objects of the type T.
8282
*
83-
* @param function a function that transforms an instance of TYPE into an instance of NEW_TYPE
84-
* @param <NEW_TYPE> the target type of the transformation
83+
* @param function a function that transforms an instance of E into an instance of T
84+
* @param <T> the target type of the transformation
8585
* @return a new FluentIterable of the new type
8686
*/
87-
<NEW_TYPE> FluentIterable<NEW_TYPE> map(Function<? super TYPE, NEW_TYPE> function);
87+
<T> FluentIterable<T> map(Function<? super E, T> function);
8888

8989
/**
9090
* Returns the contents of this Iterable as a List.
9191
*
9292
* @return a List representation of this Iterable
9393
*/
94-
List<TYPE> asList();
94+
List<E> asList();
9595

9696
/**
9797
* Utility method that iterates over iterable and adds the contents to a list.
9898
*
9999
* @param iterable the iterable to collect
100-
* @param <TYPE> the type of the objects to iterate
100+
* @param <E> the type of the objects to iterate
101101
* @return a list with all objects of the given iterator
102102
*/
103-
static <TYPE> List<TYPE> copyToList(Iterable<TYPE> iterable) {
104-
ArrayList<TYPE> copy = new ArrayList<>();
105-
Iterator<TYPE> iterator = iterable.iterator();
103+
static <E> List<E> copyToList(Iterable<E> iterable) {
104+
ArrayList<E> copy = new ArrayList<>();
105+
Iterator<E> iterator = iterable.iterator();
106106
while (iterator.hasNext()) {
107107
copy.add(iterator.next());
108108
}

fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/DecoratingIterator.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
* This class is used to realize LazyFluentIterables. It decorates a given iterator. Does not
2929
* support consecutive hasNext() calls.
3030
*/
31-
public abstract class DecoratingIterator<TYPE> implements Iterator<TYPE> {
31+
public abstract class DecoratingIterator<E> implements Iterator<E> {
3232

33-
protected final Iterator<TYPE> fromIterator;
33+
protected final Iterator<E> fromIterator;
3434

35-
private TYPE next;
35+
private E next;
3636

3737
/**
3838
* Creates an iterator that decorates the given iterator.
3939
*/
40-
public DecoratingIterator(Iterator<TYPE> fromIterator) {
40+
public DecoratingIterator(Iterator<E> fromIterator) {
4141
this.fromIterator = fromIterator;
4242
}
4343

@@ -58,11 +58,11 @@ public final boolean hasNext() {
5858
* @return the next element of the Iterable, or null if not present.
5959
*/
6060
@Override
61-
public final TYPE next() {
61+
public final E next() {
6262
if (next == null) {
6363
return fromIterator.next();
6464
} else {
65-
final TYPE result = next;
65+
final E result = next;
6666
next = null;
6767
return result;
6868
}
@@ -74,5 +74,5 @@ public final TYPE next() {
7474
*
7575
* @return the next element of the Iterable.
7676
*/
77-
public abstract TYPE computeNext();
77+
public abstract E computeNext();
7878
}

fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/LazyFluentIterable.java

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@
3535
* This is a lazy implementation of the FluentIterable interface. It evaluates all chained
3636
* operations when a terminating operation is applied.
3737
*
38-
* @param <TYPE> the type of the objects the iteration is about
38+
* @param <E> the type of the objects the iteration is about
3939
*/
40-
public class LazyFluentIterable<TYPE> implements FluentIterable<TYPE> {
40+
public class LazyFluentIterable<E> implements FluentIterable<E> {
4141

42-
private final Iterable<TYPE> iterable;
42+
private final Iterable<E> iterable;
4343

4444
/**
4545
* This constructor creates a new LazyFluentIterable. It wraps the given iterable.
4646
*
4747
* @param iterable the iterable this FluentIterable works on.
4848
*/
49-
protected LazyFluentIterable(Iterable<TYPE> iterable) {
49+
protected LazyFluentIterable(Iterable<E> iterable) {
5050
this.iterable = iterable;
5151
}
5252

@@ -66,15 +66,15 @@ protected LazyFluentIterable() {
6666
* @return a new FluentIterable object that decorates the source iterable
6767
*/
6868
@Override
69-
public FluentIterable<TYPE> filter(Predicate<? super TYPE> predicate) {
70-
return new LazyFluentIterable<TYPE>() {
69+
public FluentIterable<E> filter(Predicate<? super E> predicate) {
70+
return new LazyFluentIterable<E>() {
7171
@Override
72-
public Iterator<TYPE> iterator() {
73-
return new DecoratingIterator<TYPE>(iterable.iterator()) {
72+
public Iterator<E> iterator() {
73+
return new DecoratingIterator<E>(iterable.iterator()) {
7474
@Override
75-
public TYPE computeNext() {
75+
public E computeNext() {
7676
while (fromIterator.hasNext()) {
77-
TYPE candidate = fromIterator.next();
77+
E candidate = fromIterator.next();
7878
if (predicate.test(candidate)) {
7979
return candidate;
8080
}
@@ -93,8 +93,8 @@ public TYPE computeNext() {
9393
* @return an Optional containing the first object of this Iterable
9494
*/
9595
@Override
96-
public Optional<TYPE> first() {
97-
Iterator<TYPE> resultIterator = first(1).iterator();
96+
public Optional<E> first() {
97+
Iterator<E> resultIterator = first(1).iterator();
9898
return resultIterator.hasNext() ? Optional.of(resultIterator.next()) : Optional.empty();
9999
}
100100

@@ -106,17 +106,17 @@ public Optional<TYPE> first() {
106106
* objects.
107107
*/
108108
@Override
109-
public FluentIterable<TYPE> first(int count) {
110-
return new LazyFluentIterable<TYPE>() {
109+
public FluentIterable<E> first(int count) {
110+
return new LazyFluentIterable<E>() {
111111
@Override
112-
public Iterator<TYPE> iterator() {
113-
return new DecoratingIterator<TYPE>(iterable.iterator()) {
112+
public Iterator<E> iterator() {
113+
return new DecoratingIterator<E>(iterable.iterator()) {
114114
int currentIndex;
115115

116116
@Override
117-
public TYPE computeNext() {
117+
public E computeNext() {
118118
if (currentIndex < count && fromIterator.hasNext()) {
119-
TYPE candidate = fromIterator.next();
119+
E candidate = fromIterator.next();
120120
currentIndex++;
121121
return candidate;
122122
}
@@ -133,8 +133,8 @@ public TYPE computeNext() {
133133
* @return an Optional containing the last object of this Iterable
134134
*/
135135
@Override
136-
public Optional<TYPE> last() {
137-
Iterator<TYPE> resultIterator = last(1).iterator();
136+
public Optional<E> last() {
137+
Iterator<E> resultIterator = last(1).iterator();
138138
return resultIterator.hasNext() ? Optional.of(resultIterator.next()) : Optional.empty();
139139
}
140140

@@ -148,21 +148,21 @@ public Optional<TYPE> last() {
148148
* objects
149149
*/
150150
@Override
151-
public FluentIterable<TYPE> last(int count) {
152-
return new LazyFluentIterable<TYPE>() {
151+
public FluentIterable<E> last(int count) {
152+
return new LazyFluentIterable<E>() {
153153
@Override
154-
public Iterator<TYPE> iterator() {
155-
return new DecoratingIterator<TYPE>(iterable.iterator()) {
154+
public Iterator<E> iterator() {
155+
return new DecoratingIterator<E>(iterable.iterator()) {
156156
private int stopIndex;
157157
private int totalElementsCount;
158-
private List<TYPE> list;
158+
private List<E> list;
159159
private int currentIndex;
160160

161161
@Override
162-
public TYPE computeNext() {
162+
public E computeNext() {
163163
initialize();
164164

165-
TYPE candidate = null;
165+
E candidate = null;
166166
while (currentIndex < stopIndex && fromIterator.hasNext()) {
167167
currentIndex++;
168168
fromIterator.next();
@@ -176,7 +176,7 @@ public TYPE computeNext() {
176176
private void initialize() {
177177
if (list == null) {
178178
list = new ArrayList<>();
179-
Iterator<TYPE> newIterator = iterable.iterator();
179+
Iterator<E> newIterator = iterable.iterator();
180180
while (newIterator.hasNext()) {
181181
list.add(newIterator.next());
182182
}
@@ -191,24 +191,24 @@ private void initialize() {
191191
}
192192

193193
/**
194-
* Transforms this FluentIterable into a new one containing objects of the type NEW_TYPE.
194+
* Transforms this FluentIterable into a new one containing objects of the type T.
195195
*
196-
* @param function a function that transforms an instance of TYPE into an instance of NEW_TYPE
197-
* @param <NEW_TYPE> the target type of the transformation
196+
* @param function a function that transforms an instance of E into an instance of T
197+
* @param <T> the target type of the transformation
198198
* @return a new FluentIterable of the new type
199199
*/
200200
@Override
201-
public <NEW_TYPE> FluentIterable<NEW_TYPE> map(Function<? super TYPE, NEW_TYPE> function) {
202-
return new LazyFluentIterable<NEW_TYPE>() {
201+
public <T> FluentIterable<T> map(Function<? super E, T> function) {
202+
return new LazyFluentIterable<T>() {
203203
@Override
204-
public Iterator<NEW_TYPE> iterator() {
205-
return new DecoratingIterator<NEW_TYPE>(null) {
206-
Iterator<TYPE> oldTypeIterator = iterable.iterator();
204+
public Iterator<T> iterator() {
205+
return new DecoratingIterator<T>(null) {
206+
Iterator<E> oldTypeIterator = iterable.iterator();
207207

208208
@Override
209-
public NEW_TYPE computeNext() {
209+
public T computeNext() {
210210
if (oldTypeIterator.hasNext()) {
211-
TYPE candidate = oldTypeIterator.next();
211+
E candidate = oldTypeIterator.next();
212212
return function.apply(candidate);
213213
} else {
214214
return null;
@@ -225,15 +225,15 @@ public NEW_TYPE computeNext() {
225225
* @return a list with all remaining objects of this iteration
226226
*/
227227
@Override
228-
public List<TYPE> asList() {
228+
public List<E> asList() {
229229
return FluentIterable.copyToList(iterable);
230230
}
231231

232232
@Override
233-
public Iterator<TYPE> iterator() {
234-
return new DecoratingIterator<TYPE>(iterable.iterator()) {
233+
public Iterator<E> iterator() {
234+
return new DecoratingIterator<E>(iterable.iterator()) {
235235
@Override
236-
public TYPE computeNext() {
236+
public E computeNext() {
237237
return fromIterator.hasNext() ? fromIterator.next() : null;
238238
}
239239
};
@@ -242,7 +242,7 @@ public TYPE computeNext() {
242242
/**
243243
* @return a FluentIterable from a given iterable. Calls the LazyFluentIterable constructor.
244244
*/
245-
public static final <TYPE> FluentIterable<TYPE> from(Iterable<TYPE> iterable) {
245+
public static final <E> FluentIterable<E> from(Iterable<E> iterable) {
246246
return new LazyFluentIterable<>(iterable);
247247
}
248248

0 commit comments

Comments
 (0)