#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"?>
<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">
<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">
<position height="-1" width="-1" x="289" y="-8"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="2" language="java" name="com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/simple/SimpleFluentIterable.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="450" y="430"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="3" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/LazyFluentIterable.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="860" y="391"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="4" language="java" name="com.iluwatar.fluentinterface.fluentiterable.FluentIterable"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="794" y="55"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="5" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.DecoratingIterator"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/DecoratingIterator.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="1245" y="391"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<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">
<position height="-1" width="-1" x="793" y="-163"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<dependency id="7">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="3"/>
</dependency>
<dependency id="8">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
</dependency>
<generalization id="9">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="6"/>
</generalization>
<realization id="10">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="4"/>
</realization>
<dependency id="11">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="4"/>
</dependency>
<realization id="12">
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="4"/>
</realization>
<dependency id="13">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="5"/>
</dependency>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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">
<position height="-1" width="-1" x="289" y="-8"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="false" protected="false" private="false" static="false"/>
<operations public="true" package="true" protected="true" private="false" static="true"/>
</display>
</class>
<class id="2" language="java" name="com.iluwatar.fluentinterface.fluentiterable.simple.SimpleFluentIterable"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/simple/SimpleFluentIterable.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="450" y="430"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="3" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/LazyFluentIterable.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="860" y="391"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="4" language="java" name="com.iluwatar.fluentinterface.fluentiterable.FluentIterable"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/FluentIterable.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="794" y="55"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="5" language="java" name="com.iluwatar.fluentinterface.fluentiterable.lazy.DecoratingIterator"
project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/fluentiterable/lazy/DecoratingIterator.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="1245" y="391"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="6" language="java" name="java.lang.Iterable" project="fluentinterface"
file="/opt/Softwares/Eclipses/MARS/eclipse/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="793" y="-163"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<dependency id="7">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
</dependency>
<realization id="8">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="4"/>
</realization>
<dependency id="9">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="5"/>
</dependency>
<generalization id="10">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="6"/>
</generalization>
<dependency id="11">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="3"/>
</dependency>
<dependency id="12">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="4"/>
</dependency>
<realization id="13">
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="4"/>
</realization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="true" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

View File

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

View File

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

View File

@ -124,7 +124,7 @@ public class SimpleFluentIterable<TYPE> implements FluentIterable<TYPE> {
*/
@Override
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();
while (iterator.hasNext()) {
temporaryList.add(function.apply(iterator.next()));