Java 11 migrate remaining p (#1122)
* Moves partial-response to Java 11 * Moves pipeline to Java 11 * Moves poison-pill to Java 11 * Moves priority-queue to Java 11 * Moves private-class-data to Java 11 * Moves producer-consumer to Java 11 * Moves promise to Java 11 * Moves property to Java 11 * Moves prototype to Java 11 * Moves proxy to Java 11 * Corrects checkstyle errors * Fixes build for pipeline pattern
This commit is contained in:
committed by
Ilkka Seppälä
parent
1401accb4f
commit
428efc7d53
@ -46,24 +46,23 @@ public class App {
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
HeroFactory factory = new HeroFactoryImpl(
|
||||
var factory = new HeroFactoryImpl(
|
||||
new ElfMage("cooking"),
|
||||
new ElfWarlord("cleaning"),
|
||||
new ElfBeast("protecting")
|
||||
);
|
||||
Mage mage = factory.createMage();
|
||||
Warlord warlord = factory.createWarlord();
|
||||
Beast beast = factory.createBeast();
|
||||
var mage = factory.createMage();
|
||||
var warlord = factory.createWarlord();
|
||||
var beast = factory.createBeast();
|
||||
LOGGER.info(mage.toString());
|
||||
LOGGER.info(warlord.toString());
|
||||
LOGGER.info(beast.toString());
|
||||
|
||||
factory =
|
||||
new HeroFactoryImpl(
|
||||
new OrcMage("axe"),
|
||||
new OrcWarlord("sword"),
|
||||
new OrcBeast("laser")
|
||||
);
|
||||
factory = new HeroFactoryImpl(
|
||||
new OrcMage("axe"),
|
||||
new OrcWarlord("sword"),
|
||||
new OrcBeast("laser")
|
||||
);
|
||||
mage = factory.createMage();
|
||||
warlord = factory.createWarlord();
|
||||
beast = factory.createBeast();
|
||||
|
@ -28,9 +28,11 @@ package com.iluwatar.prototype;
|
||||
*/
|
||||
public abstract class Beast implements Prototype {
|
||||
|
||||
public Beast() { }
|
||||
public Beast() {
|
||||
}
|
||||
|
||||
public Beast(Beast source) { }
|
||||
public Beast(Beast source) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Beast copy();
|
||||
|
@ -60,15 +60,11 @@ public class ElfBeast extends Beast {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ElfBeast other = (ElfBeast) obj;
|
||||
var other = (ElfBeast) obj;
|
||||
if (helpType == null) {
|
||||
if (other.helpType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!helpType.equals(other.helpType)) {
|
||||
return false;
|
||||
return other.helpType == null;
|
||||
}
|
||||
return true;
|
||||
return helpType.equals(other.helpType);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,14 +60,10 @@ public class ElfMage extends Mage {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ElfMage other = (ElfMage) obj;
|
||||
var other = (ElfMage) obj;
|
||||
if (helpType == null) {
|
||||
if (other.helpType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!helpType.equals(other.helpType)) {
|
||||
return false;
|
||||
return other.helpType == null;
|
||||
}
|
||||
return true;
|
||||
return helpType.equals(other.helpType);
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +60,10 @@ public class ElfWarlord extends Warlord {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ElfWarlord other = (ElfWarlord) obj;
|
||||
var other = (ElfWarlord) obj;
|
||||
if (helpType == null) {
|
||||
if (other.helpType != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!helpType.equals(other.helpType)) {
|
||||
return false;
|
||||
return other.helpType == null;
|
||||
}
|
||||
return true;
|
||||
return helpType.equals(other.helpType);
|
||||
}
|
||||
}
|
@ -28,9 +28,11 @@ package com.iluwatar.prototype;
|
||||
*/
|
||||
public abstract class Mage implements Prototype {
|
||||
|
||||
public Mage() { }
|
||||
public Mage() {
|
||||
}
|
||||
|
||||
public Mage(Mage source) { }
|
||||
public Mage(Mage source) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Mage copy();
|
||||
|
@ -60,15 +60,11 @@ public class OrcBeast extends Beast {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
OrcBeast other = (OrcBeast) obj;
|
||||
var other = (OrcBeast) obj;
|
||||
if (weapon == null) {
|
||||
if (other.weapon != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!weapon.equals(other.weapon)) {
|
||||
return false;
|
||||
return other.weapon == null;
|
||||
}
|
||||
return true;
|
||||
return weapon.equals(other.weapon);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,14 +60,10 @@ public class OrcMage extends Mage {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
OrcMage other = (OrcMage) obj;
|
||||
var other = (OrcMage) obj;
|
||||
if (weapon == null) {
|
||||
if (other.weapon != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!weapon.equals(other.weapon)) {
|
||||
return false;
|
||||
return other.weapon == null;
|
||||
}
|
||||
return true;
|
||||
return weapon.equals(other.weapon);
|
||||
}
|
||||
}
|
||||
|
@ -60,14 +60,10 @@ public class OrcWarlord extends Warlord {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
OrcWarlord other = (OrcWarlord) obj;
|
||||
var other = (OrcWarlord) obj;
|
||||
if (weapon == null) {
|
||||
if (other.weapon != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!weapon.equals(other.weapon)) {
|
||||
return false;
|
||||
return other.weapon == null;
|
||||
}
|
||||
return true;
|
||||
return weapon.equals(other.weapon);
|
||||
}
|
||||
}
|
||||
|
@ -28,9 +28,11 @@ package com.iluwatar.prototype;
|
||||
*/
|
||||
public abstract class Warlord implements Prototype {
|
||||
|
||||
public Warlord() { }
|
||||
public Warlord() {
|
||||
}
|
||||
|
||||
public Warlord(Warlord source) { }
|
||||
public Warlord(Warlord source) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Warlord copy();
|
||||
|
@ -26,15 +26,12 @@ package com.iluwatar.prototype;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
App.main(new String[]{});
|
||||
}
|
||||
}
|
||||
|
@ -23,37 +23,40 @@
|
||||
|
||||
package com.iluwatar.prototype;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
/**
|
||||
* Date: 12/28/15 - 8:45 PM
|
||||
*
|
||||
* @param <P> Prototype
|
||||
* @author Jeroen Meulemeester
|
||||
*/
|
||||
public class PrototypeTest<P extends Prototype> {
|
||||
static Collection<Object[]> dataProvider() {
|
||||
return List.of(
|
||||
new Object[]{new OrcBeast("axe"), "Orcish wolf attacks with axe"},
|
||||
new Object[]{new OrcMage("sword"), "Orcish mage attacks with sword"},
|
||||
new Object[]{new OrcWarlord("laser"), "Orcish warlord attacks with laser"},
|
||||
new Object[]{new ElfBeast("cooking"), "Elven eagle helps in cooking"},
|
||||
new Object[]{new ElfMage("cleaning"), "Elven mage helps in cleaning"},
|
||||
new Object[]{new ElfWarlord("protecting"), "Elven warlord helps in protecting"}
|
||||
new Object[]{new OrcBeast("axe"), "Orcish wolf attacks with axe"},
|
||||
new Object[]{new OrcMage("sword"), "Orcish mage attacks with sword"},
|
||||
new Object[]{new OrcWarlord("laser"), "Orcish warlord attacks with laser"},
|
||||
new Object[]{new ElfBeast("cooking"), "Elven eagle helps in cooking"},
|
||||
new Object[]{new ElfMage("cleaning"), "Elven mage helps in cleaning"},
|
||||
new Object[]{new ElfWarlord("protecting"), "Elven warlord helps in protecting"}
|
||||
);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("dataProvider")
|
||||
public void testPrototype(P testedPrototype, String expectedToString) throws Exception {
|
||||
public void testPrototype(P testedPrototype, String expectedToString) {
|
||||
assertEquals(expectedToString, testedPrototype.toString());
|
||||
|
||||
final Object clone = testedPrototype.copy();
|
||||
final var clone = testedPrototype.copy();
|
||||
assertNotNull(clone);
|
||||
assertNotSame(clone, testedPrototype);
|
||||
assertSame(testedPrototype.getClass(), clone.getClass());
|
||||
|
Reference in New Issue
Block a user