mirror of https://github.com/deavmi/JavaOCP
Compare commits
4 Commits
f42b41e610
...
bca65ddc0c
Author | SHA1 | Date |
---|---|---|
Tristan B. Velloza Kildaire | bca65ddc0c | |
Tristan B. Velloza Kildaire | 6b1bcde01f | |
Tristan B. Velloza Kildaire | e2c239a7f3 | |
Tristan B. Velloza Kildaire | f60f559580 |
|
@ -46,6 +46,12 @@ public class App
|
|||
System.out.println("Double (n-arity): "+Arrays.toString(doubles));
|
||||
}
|
||||
|
||||
public static void doThing(Integer i, Integer k, Integer j)
|
||||
{
|
||||
System.out.println("Boxed Integer (3 arity): "+i+" "+k+" "+j);
|
||||
}
|
||||
|
||||
// TODO: Disable below THEN above is chosen
|
||||
public static void doThing(long i, long k, long j)
|
||||
{
|
||||
System.out.println("Long (3 arity): "+i+" "+k+" "+j);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/target/
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ocp.practice.basics</groupId>
|
||||
<artifactId>MoreStreams</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<name>MoreStreams</name>
|
||||
<description>A simple MoreStreams.</description>
|
||||
<!-- FIXME change it to the project's website -->
|
||||
<url>http://www.example.com</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
|
@ -0,0 +1,42 @@
|
|||
package ocp.practice.basics.MoreStreams;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Practicing streams and linkage
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
// Practice dirtying streams
|
||||
practiceDirtyLinkage();
|
||||
}
|
||||
|
||||
/**
|
||||
* When you do a operation on a stream
|
||||
* then it "dirties" the original stream
|
||||
* meaning another thing cannot be linked.
|
||||
*
|
||||
* This is why you must always use to new
|
||||
* stream created by the method call which
|
||||
* dirtied the original one so as to have
|
||||
* an "undirtied" one which can be linked.
|
||||
*/
|
||||
private static void practiceDirtyLinkage()
|
||||
{
|
||||
Stream<Integer> myStream = Stream.of(10, 20, 30);
|
||||
|
||||
// myStream.map((item) -> item+10);
|
||||
|
||||
myStream.forEach(System.out::print); // 10 20 30
|
||||
|
||||
var f = List.of(1,2,3,4);
|
||||
f.forEach((d) -> System.out.print(d));
|
||||
f.replaceAll(d->d+10);
|
||||
Arrays.asList(1,2,3,4);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project name="MoreStreams" xmlns="http://maven.apache.org/DECORATION/1.8.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.8.0 http://maven.apache.org/xsd/decoration-1.8.0.xsd">
|
||||
<bannerLeft>
|
||||
<name>MoreStreams</name>
|
||||
<src>https://maven.apache.org/images/apache-maven-project.png</src>
|
||||
<href>https://www.apache.org/</href>
|
||||
</bannerLeft>
|
||||
|
||||
<bannerRight>
|
||||
<src>https://maven.apache.org/images/maven-logo-black-on-white.png</src>
|
||||
<href>https://maven.apache.org/</href>
|
||||
</bannerRight>
|
||||
|
||||
<skin>
|
||||
<groupId>org.apache.maven.skins</groupId>
|
||||
<artifactId>maven-fluido-skin</artifactId>
|
||||
<version>1.7</version>
|
||||
</skin>
|
||||
|
||||
<body>
|
||||
<menu ref="parent" />
|
||||
<menu ref="reports" />
|
||||
</body>
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
package ocp.practice.basics.MoreStreams;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue