BAEL-376 - Adding more test code
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
package com.baeldung.generics;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Building {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Building.class);
|
||||
|
||||
public void paint() {
|
||||
LOGGER.info("Building");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package com.baeldung.generics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -21,9 +23,7 @@ public class Generics {
|
||||
// example of a generic method with a wild card, this method can be used
|
||||
// with a list of any subtype of Building
|
||||
public static boolean paintAllBuildings(List<? extends Building> buildings) {
|
||||
for (Building building : buildings) {
|
||||
building.paint();
|
||||
}
|
||||
buildings.stream().forEach(Building::paint);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
12
core-java/src/main/java/com/baeldung/generics/House.java
Normal file
12
core-java/src/main/java/com/baeldung/generics/House.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.generics;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class House extends Building {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(House.class);
|
||||
|
||||
public void paint() {
|
||||
LOGGER.info("House");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
public class SubBuilding extends Building {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user