Skip to content

Commit efa7e01

Browse files
committed
iluwatar#184 polished a few rough edges, class diagram change, and removed warnings
1 parent 0148cd7 commit efa7e01

File tree

5 files changed

+108
-128
lines changed

5 files changed

+108
-128
lines changed
23.7 KB
Loading
+99-99
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,100 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3-
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
4-
<class id="1" language="java" name="com.iluwatar.fluentinterface.App" project="fluentinterface"
5-
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/App.java" binary="false" corner="BOTTOM_RIGHT">
6-
<position height="-1" width="-1" x="289" y="-8"/>
7-
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
8-
sort-features="false" accessors="true" visibility="true">
9-
<attributes public="true" package="true" protected="true" private="true" static="true"/>
10-
<operations public="true" package="true" protected="true" private="true" static="true"/>
11-
</display>
12-
</class>
13-
<class id="2" language="java" name="com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable"
14-
project="fluentinterface"
15-
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/simple/SimpleFluentIterable.java"
16-
binary="false" corner="BOTTOM_RIGHT">
17-
<position height="-1" width="-1" x="450" y="430"/>
18-
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
19-
sort-features="false" accessors="true" visibility="true">
20-
<attributes public="true" package="true" protected="true" private="true" static="true"/>
21-
<operations public="true" package="true" protected="true" private="true" static="true"/>
22-
</display>
23-
</class>
24-
<class id="3" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable"
25-
project="fluentinterface"
26-
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/LazyFluentIterable.java"
27-
binary="false" corner="BOTTOM_RIGHT">
28-
<position height="-1" width="-1" x="860" y="391"/>
29-
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
30-
sort-features="false" accessors="true" visibility="true">
31-
<attributes public="true" package="true" protected="true" private="true" static="true"/>
32-
<operations public="true" package="true" protected="true" private="true" static="true"/>
33-
</display>
34-
</class>
35-
<interface id="4" language="java" name="com.iluwatar.fluentinterface.fluentiterable.FluentIterable"
36-
project="fluentinterface"
37-
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java" binary="false"
38-
corner="BOTTOM_RIGHT">
39-
<position height="-1" width="-1" x="794" y="55"/>
40-
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
41-
sort-features="false" accessors="true" visibility="true">
42-
<attributes public="true" package="true" protected="true" private="true" static="true"/>
43-
<operations public="true" package="true" protected="true" private="true" static="true"/>
44-
</display>
45-
</interface>
46-
<class id="5" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.DecoratingIterator"
47-
project="fluentinterface"
48-
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/DecoratingIterator.java"
49-
binary="false" corner="BOTTOM_RIGHT">
50-
<position height="-1" width="-1" x="1245" y="391"/>
51-
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
52-
sort-features="false" accessors="true" visibility="true">
53-
<attributes public="true" package="true" protected="true" private="true" static="true"/>
54-
<operations public="true" package="true" protected="true" private="true" static="true"/>
55-
</display>
56-
</class>
57-
<interface id="6" language="java" name="java.lang.Iterable" project="fluentinterface"
58-
file="C:/Program Files/Java/jdk1.8.0/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
59-
<position height="-1" width="-1" x="793" y="-163"/>
60-
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
61-
sort-features="false" accessors="true" visibility="true">
62-
<attributes public="true" package="true" protected="true" private="true" static="true"/>
63-
<operations public="true" package="true" protected="true" private="true" static="true"/>
64-
</display>
65-
</interface>
66-
<dependency id="7">
67-
<end type="SOURCE" refId="1"/>
68-
<end type="TARGET" refId="3"/>
69-
</dependency>
70-
<dependency id="8">
71-
<end type="SOURCE" refId="1"/>
72-
<end type="TARGET" refId="2"/>
73-
</dependency>
74-
<generalization id="9">
75-
<end type="SOURCE" refId="4"/>
76-
<end type="TARGET" refId="6"/>
77-
</generalization>
78-
<realization id="10">
79-
<end type="SOURCE" refId="3"/>
80-
<end type="TARGET" refId="4"/>
81-
</realization>
82-
<dependency id="11">
83-
<end type="SOURCE" refId="1"/>
84-
<end type="TARGET" refId="4"/>
85-
</dependency>
86-
<realization id="12">
87-
<end type="SOURCE" refId="2"/>
88-
<end type="TARGET" refId="4"/>
89-
</realization>
90-
<dependency id="13">
91-
<end type="SOURCE" refId="3"/>
92-
<end type="TARGET" refId="5"/>
93-
</dependency>
94-
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
95-
sort-features="false" accessors="true" visibility="true">
96-
<attributes public="true" package="true" protected="true" private="true" static="true"/>
97-
<operations public="true" package="true" protected="true" private="true" static="true"/>
98-
</classifier-display>
99-
<association-display labels="true" multiplicity="true"/>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
4+
<class id="1" language="java" name="com.iluwatar.fluentinterface.App" project="fluentinterface"
5+
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/App.java" binary="false" corner="BOTTOM_RIGHT">
6+
<position height="-1" width="-1" x="289" y="-8"/>
7+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
8+
sort-features="false" accessors="true" visibility="true">
9+
<attributes public="true" package="false" protected="false" private="false" static="false"/>
10+
<operations public="true" package="true" protected="true" private="false" static="true"/>
11+
</display>
12+
</class>
13+
<class id="2" language="java" name="com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable"
14+
project="fluentinterface"
15+
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/simple/SimpleFluentIterable.java"
16+
binary="false" corner="BOTTOM_RIGHT">
17+
<position height="-1" width="-1" x="450" y="430"/>
18+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
19+
sort-features="false" accessors="true" visibility="true">
20+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
21+
<operations public="true" package="true" protected="true" private="true" static="true"/>
22+
</display>
23+
</class>
24+
<class id="3" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable"
25+
project="fluentinterface"
26+
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/LazyFluentIterable.java"
27+
binary="false" corner="BOTTOM_RIGHT">
28+
<position height="-1" width="-1" x="860" y="391"/>
29+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
30+
sort-features="false" accessors="true" visibility="true">
31+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
32+
<operations public="true" package="true" protected="true" private="true" static="true"/>
33+
</display>
34+
</class>
35+
<interface id="4" language="java" name="com.iluwatar.fluentinterface.fluentiterable.FluentIterable"
36+
project="fluentinterface"
37+
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java" binary="false"
38+
corner="BOTTOM_RIGHT">
39+
<position height="-1" width="-1" x="794" y="55"/>
40+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
41+
sort-features="false" accessors="true" visibility="true">
42+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
43+
<operations public="true" package="true" protected="true" private="true" static="true"/>
44+
</display>
45+
</interface>
46+
<class id="5" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.DecoratingIterator"
47+
project="fluentinterface"
48+
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/DecoratingIterator.java"
49+
binary="false" corner="BOTTOM_RIGHT">
50+
<position height="-1" width="-1" x="1245" y="391"/>
51+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
52+
sort-features="false" accessors="true" visibility="true">
53+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
54+
<operations public="true" package="true" protected="true" private="true" static="true"/>
55+
</display>
56+
</class>
57+
<interface id="6" language="java" name="java.lang.Iterable" project="fluentinterface"
58+
file="/opt/Softwares/Eclipses/MARS/eclipse/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
59+
<position height="-1" width="-1" x="793" y="-163"/>
60+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
61+
sort-features="false" accessors="true" visibility="true">
62+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
63+
<operations public="true" package="true" protected="true" private="true" static="true"/>
64+
</display>
65+
</interface>
66+
<dependency id="7">
67+
<end type="SOURCE" refId="1"/>
68+
<end type="TARGET" refId="2"/>
69+
</dependency>
70+
<realization id="8">
71+
<end type="SOURCE" refId="3"/>
72+
<end type="TARGET" refId="4"/>
73+
</realization>
74+
<dependency id="9">
75+
<end type="SOURCE" refId="3"/>
76+
<end type="TARGET" refId="5"/>
77+
</dependency>
78+
<generalization id="10">
79+
<end type="SOURCE" refId="4"/>
80+
<end type="TARGET" refId="6"/>
81+
</generalization>
82+
<dependency id="11">
83+
<end type="SOURCE" refId="1"/>
84+
<end type="TARGET" refId="3"/>
85+
</dependency>
86+
<dependency id="12">
87+
<end type="SOURCE" refId="1"/>
88+
<end type="TARGET" refId="4"/>
89+
</dependency>
90+
<realization id="13">
91+
<end type="SOURCE" refId="2"/>
92+
<end type="TARGET" refId="4"/>
93+
</realization>
94+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="true" signature="true"
95+
sort-features="false" accessors="true" visibility="true">
96+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
97+
<operations public="true" package="true" protected="true" private="true" static="true"/>
98+
</classifier-display>
99+
<association-display labels="true" multiplicity="true"/>
100100
</class-diagram>

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

+6-25
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,12 @@ public class App {
2525

2626
public static void main(String[] args) {
2727

28-
List<Integer> integerList = new ArrayList<Integer>() {
29-
{
30-
add(1);
31-
add(-61);
32-
add(14);
33-
add(-22);
34-
add(18);
35-
add(-87);
36-
add(6);
37-
add(64);
38-
add(-82);
39-
add(26);
40-
add(-98);
41-
add(97);
42-
add(45);
43-
add(23);
44-
add(2);
45-
add(-68);
46-
add(45);
47-
}
48-
};
28+
List<Integer> integerList = new ArrayList<>();
29+
integerList.addAll(Arrays.asList(
30+
1, -61, 14, -22, 18, -87, 6, 64, -82, 26, -98, 97,
31+
45, 23, 2, -68, 45
32+
));
33+
4934
prettyPrint("The initial list contains: ", integerList);
5035

5136
List<Integer> firstFiveNegatives =
@@ -105,10 +90,6 @@ private static <TYPE> void prettyPrint(String prefix, Iterable<TYPE> iterable) {
10590
prettyPrint(", ", prefix, ".", iterable);
10691
}
10792

108-
private static <TYPE> void prettyPrint(String prefix, String suffix, Iterable<TYPE> iterable) {
109-
prettyPrint(", ", prefix, suffix, iterable);
110-
}
111-
11293
private static <TYPE> void prettyPrint(String delimiter, String prefix, String suffix,
11394
Iterable<TYPE> iterable) {
11495
StringJoiner joiner = new StringJoiner(delimiter, prefix, ".");

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package com.iluwatar.fluentinterface.fluentiterable.lazy;
22

3-
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
4-
53
import java.util.ArrayList;
64
import java.util.Iterator;
75
import java.util.List;
86
import java.util.Optional;
9-
import java.util.function.Consumer;
107
import java.util.function.Function;
118
import java.util.function.Predicate;
129

10+
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
11+
1312
/**
1413
* This is a lazy implementation of the FluentIterable interface. It evaluates all chained
1514
* operations when a terminating operation is applied.

fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/simple/SimpleFluentIterable.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public final FluentIterable<TYPE> last(int count) {
124124
*/
125125
@Override
126126
public final <NEW_TYPE> FluentIterable<NEW_TYPE> map(Function<? super TYPE, NEW_TYPE> function) {
127-
List<NEW_TYPE> temporaryList = new ArrayList();
127+
List<NEW_TYPE> temporaryList = new ArrayList<>();
128128
Iterator<TYPE> iterator = iterator();
129129
while (iterator.hasNext()) {
130130
temporaryList.add(function.apply(iterator.next()));

0 commit comments

Comments
 (0)