#184 polished a few rough edges, class diagram change, and removed warnings

This commit is contained in:
Narendra Pathai 2015-09-10 13:12:36 +05:30
parent 0148cd7d2a
commit efa7e01223
5 changed files with 108 additions and 128 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1,100 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true" <class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true"> realizations="true" associations="true" dependencies="false" nesting-relationships="true">
<class id="1" language="java" name="com.iluwatar.fluentinterface.App" project="fluentinterface" <class id="1" language="java" name="com.iluwatar.fluentinterface.App" project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/App.java" binary="false" corner="BOTTOM_RIGHT"> file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/App.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="289" y="-8"/> <position height="-1" width="-1" x="289" y="-8"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="false" protected="false" private="false" static="false"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="false" static="true"/>
</display> </display>
</class> </class>
<class id="2" language="java" name="com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable" <class id="2" language="java" name="com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable"
project="fluentinterface" project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/simple/SimpleFluentIterable.java" file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/simple/SimpleFluentIterable.java"
binary="false" corner="BOTTOM_RIGHT"> binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="450" y="430"/> <position height="-1" width="-1" x="450" y="430"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</display> </display>
</class> </class>
<class id="3" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable" <class id="3" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable"
project="fluentinterface" project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/LazyFluentIterable.java" file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/LazyFluentIterable.java"
binary="false" corner="BOTTOM_RIGHT"> binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="860" y="391"/> <position height="-1" width="-1" x="860" y="391"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</display> </display>
</class> </class>
<interface id="4" language="java" name="com.iluwatar.fluentinterface.fluentiterable.FluentIterable" <interface id="4" language="java" name="com.iluwatar.fluentinterface.fluentiterable.FluentIterable"
project="fluentinterface" project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java" binary="false" file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java" binary="false"
corner="BOTTOM_RIGHT"> corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="794" y="55"/> <position height="-1" width="-1" x="794" y="55"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</display> </display>
</interface> </interface>
<class id="5" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.DecoratingIterator" <class id="5" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.DecoratingIterator"
project="fluentinterface" project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/DecoratingIterator.java" file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/DecoratingIterator.java"
binary="false" corner="BOTTOM_RIGHT"> binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="1245" y="391"/> <position height="-1" width="-1" x="1245" y="391"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</display> </display>
</class> </class>
<interface id="6" language="java" name="java.lang.Iterable" project="fluentinterface" <interface id="6" language="java" name="java.lang.Iterable" project="fluentinterface"
file="C:/Program Files/Java/jdk1.8.0/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT"> file="/opt/Softwares/Eclipses/MARS/eclipse/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="793" y="-163"/> <position height="-1" width="-1" x="793" y="-163"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</display> </display>
</interface> </interface>
<dependency id="7"> <dependency id="7">
<end type="SOURCE" refId="1"/> <end type="SOURCE" refId="1"/>
<end type="TARGET" refId="3"/> <end type="TARGET" refId="2"/>
</dependency> </dependency>
<dependency id="8"> <realization id="8">
<end type="SOURCE" refId="1"/> <end type="SOURCE" refId="3"/>
<end type="TARGET" refId="2"/> <end type="TARGET" refId="4"/>
</dependency> </realization>
<generalization id="9"> <dependency id="9">
<end type="SOURCE" refId="4"/> <end type="SOURCE" refId="3"/>
<end type="TARGET" refId="6"/> <end type="TARGET" refId="5"/>
</generalization> </dependency>
<realization id="10"> <generalization id="10">
<end type="SOURCE" refId="3"/> <end type="SOURCE" refId="4"/>
<end type="TARGET" refId="4"/> <end type="TARGET" refId="6"/>
</realization> </generalization>
<dependency id="11"> <dependency id="11">
<end type="SOURCE" refId="1"/> <end type="SOURCE" refId="1"/>
<end type="TARGET" refId="4"/> <end type="TARGET" refId="3"/>
</dependency> </dependency>
<realization id="12"> <dependency id="12">
<end type="SOURCE" refId="2"/> <end type="SOURCE" refId="1"/>
<end type="TARGET" refId="4"/> <end type="TARGET" refId="4"/>
</realization> </dependency>
<dependency id="13"> <realization id="13">
<end type="SOURCE" refId="3"/> <end type="SOURCE" refId="2"/>
<end type="TARGET" refId="5"/> <end type="TARGET" refId="4"/>
</dependency> </realization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true" <classifier-display autosize="true" stereotype="true" package="true" initial-value="true" signature="true"
sort-features="false" accessors="true" visibility="true"> sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/> <attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/> <operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display> </classifier-display>
<association-display labels="true" multiplicity="true"/> <association-display labels="true" multiplicity="true"/>
</class-diagram> </class-diagram>

View File

@ -25,27 +25,12 @@ public class App {
public static void main(String[] args) { public static void main(String[] args) {
List<Integer> integerList = new ArrayList<Integer>() { List<Integer> integerList = new ArrayList<>();
{ integerList.addAll(Arrays.asList(
add(1); 1, -61, 14, -22, 18, -87, 6, 64, -82, 26, -98, 97,
add(-61); 45, 23, 2, -68, 45
add(14); ));
add(-22);
add(18);
add(-87);
add(6);
add(64);
add(-82);
add(26);
add(-98);
add(97);
add(45);
add(23);
add(2);
add(-68);
add(45);
}
};
prettyPrint("The initial list contains: ", integerList); prettyPrint("The initial list contains: ", integerList);
List<Integer> firstFiveNegatives = List<Integer> firstFiveNegatives =
@ -105,10 +90,6 @@ public class App {
prettyPrint(", ", prefix, ".", iterable); prettyPrint(", ", prefix, ".", iterable);
} }
private static <TYPE> void prettyPrint(String prefix, String suffix, Iterable<TYPE> iterable) {
prettyPrint(", ", prefix, suffix, iterable);
}
private static <TYPE> void prettyPrint(String delimiter, String prefix, String suffix, private static <TYPE> void prettyPrint(String delimiter, String prefix, String suffix,
Iterable<TYPE> iterable) { Iterable<TYPE> iterable) {
StringJoiner joiner = new StringJoiner(delimiter, prefix, "."); StringJoiner joiner = new StringJoiner(delimiter, prefix, ".");

View File

@ -1,15 +1,14 @@
package com.iluwatar.fluentinterface.fluentiterable.lazy; package com.iluwatar.fluentinterface.fluentiterable.lazy;
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
/** /**
* This is a lazy implementation of the FluentIterable interface. It evaluates all chained * This is a lazy implementation of the FluentIterable interface. It evaluates all chained
* operations when a terminating operation is applied. * operations when a terminating operation is applied.

View File

@ -124,7 +124,7 @@ public class SimpleFluentIterable<TYPE> implements FluentIterable<TYPE> {
*/ */
@Override @Override
public final <NEW_TYPE> FluentIterable<NEW_TYPE> map(Function<? super TYPE, NEW_TYPE> function) { public final <NEW_TYPE> FluentIterable<NEW_TYPE> map(Function<? super TYPE, NEW_TYPE> function) {
List<NEW_TYPE> temporaryList = new ArrayList(); List<NEW_TYPE> temporaryList = new ArrayList<>();
Iterator<TYPE> iterator = iterator(); Iterator<TYPE> iterator = iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
temporaryList.add(function.apply(iterator.next())); temporaryList.add(function.apply(iterator.next()));