Skip to content

Commit e491f95

Browse files
author
Eugen Paraschiv
committed
java guava examples
1 parent 361111b commit e491f95

File tree

2 files changed

+14
-35
lines changed

2 files changed

+14
-35
lines changed

guava/pom.xml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,35 +65,6 @@
6565
<groupId>org.apache.maven.plugins</groupId>
6666
<artifactId>maven-surefire-plugin</artifactId>
6767
<version>${maven-surefire-plugin.version}</version>
68-
<configuration>
69-
<excludes>
70-
<!-- <exclude>**/*ProductionTest.java</exclude> -->
71-
</excludes>
72-
<systemPropertyVariables>
73-
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
74-
</systemPropertyVariables>
75-
</configuration>
76-
</plugin>
77-
78-
<plugin>
79-
<groupId>org.codehaus.cargo</groupId>
80-
<artifactId>cargo-maven2-plugin</artifactId>
81-
<version>${cargo-maven2-plugin.version}</version>
82-
<configuration>
83-
<wait>true</wait>
84-
<container>
85-
<containerId>jetty8x</containerId>
86-
<type>embedded</type>
87-
<systemProperties>
88-
<!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
89-
</systemProperties>
90-
</container>
91-
<configuration>
92-
<properties>
93-
<cargo.servlet.port>8082</cargo.servlet.port>
94-
</properties>
95-
</configuration>
96-
</configuration>
9768
</plugin>
9869

9970
</plugins>

guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamples.java renamed to guava/src/test/java/org/baeldung/guava/collections/GuavaCollectionsExamplesTest.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,36 @@
77
import com.google.common.base.Function;
88
import com.google.common.collect.Lists;
99

10-
public class GuavaCollectionsExamples {
10+
public class GuavaCollectionsExamplesTest {
11+
12+
// tests
1113

12-
@SuppressWarnings({ "unused", "unchecked" })
1314
@Test
14-
public final void whenCastingAllElementsOfACollectionToSubtype_thenCastIsOK() {
15+
public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK() {
1516
final class CastFunction<F, T extends F> implements Function<F, T> {
16-
@Override
1717
@SuppressWarnings("unchecked")
18+
@Override
1819
public final T apply(final F from) {
1920
return (T) from;
2021
}
2122
}
2223

2324
final List<Number> originalList = Lists.newArrayList();
24-
final List<Integer> selectedProductsQuick = (List<Integer>) (List<? extends Number>) originalList;
2525
final List<Integer> selectedProducts = Lists.transform(originalList, new CastFunction<Number, Integer>());
2626
System.out.println(selectedProducts);
2727
}
2828

29+
@SuppressWarnings({ "unchecked" })
2930
@Test
30-
public final void when_then() {
31+
public final void whenDowncastingGenerifiedCollectionToNewGenerifiedCollection_thenCastIsOK2() {
32+
final List<Number> originalList = Lists.newArrayList();
33+
final List<Integer> selectedProducts = (List<Integer>) (List<? extends Number>) originalList;
34+
System.out.println(selectedProducts);
35+
}
3136

37+
@Test
38+
public final void when_then() {
39+
//
3240
}
3341

3442
}

0 commit comments

Comments
 (0)