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:
Anurag Agarwal
2020-01-16 11:36:36 +05:30
committed by Ilkka Seppälä
parent 1401accb4f
commit 428efc7d53
82 changed files with 532 additions and 601 deletions

View File

@ -49,36 +49,36 @@ public class App {
*/
public static void main(String[] args) {
/* set up */
Prototype charProto = new Character();
var charProto = new Character();
charProto.set(Stats.STRENGTH, 10);
charProto.set(Stats.AGILITY, 10);
charProto.set(Stats.ARMOR, 10);
charProto.set(Stats.ATTACK_POWER, 10);
Character mageProto = new Character(Type.MAGE, charProto);
var mageProto = new Character(Type.MAGE, charProto);
mageProto.set(Stats.INTELLECT, 15);
mageProto.set(Stats.SPIRIT, 10);
Character warProto = new Character(Type.WARRIOR, charProto);
var warProto = new Character(Type.WARRIOR, charProto);
warProto.set(Stats.RAGE, 15);
warProto.set(Stats.ARMOR, 15); // boost default armor for warrior
Character rogueProto = new Character(Type.ROGUE, charProto);
var rogueProto = new Character(Type.ROGUE, charProto);
rogueProto.set(Stats.ENERGY, 15);
rogueProto.set(Stats.AGILITY, 15); // boost default agility for rogue
/* usage */
Character mag = new Character("Player_1", mageProto);
var mag = new Character("Player_1", mageProto);
mag.set(Stats.ARMOR, 8);
LOGGER.info(mag.toString());
Character warrior = new Character("Player_2", warProto);
var warrior = new Character("Player_2", warProto);
LOGGER.info(warrior.toString());
Character rogue = new Character("Player_3", rogueProto);
var rogue = new Character("Player_3", rogueProto);
LOGGER.info(rogue.toString());
Character rogueDouble = new Character("Player_4", rogue);
var rogueDouble = new Character("Player_4", rogue);
rogueDouble.set(Stats.ATTACK_POWER, 12);
LOGGER.info(rogueDouble.toString());
}

View File

@ -93,7 +93,7 @@ public class Character implements Prototype {
@Override
public Integer get(Stats stat) {
boolean containsValue = properties.containsKey(stat);
var containsValue = properties.containsKey(stat);
if (containsValue) {
return properties.get(stat);
} else {
@ -118,7 +118,7 @@ public class Character implements Prototype {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
var builder = new StringBuilder();
if (name != null) {
builder.append("Player: ").append(name).append('\n');
}
@ -128,8 +128,8 @@ public class Character implements Prototype {
}
builder.append("Stats:\n");
for (Stats stat : Stats.values()) {
Integer value = this.get(stat);
for (var stat : Stats.values()) {
var value = this.get(stat);
if (value == null) {
continue;
}

View File

@ -26,15 +26,12 @@ package com.iluwatar.property;
import org.junit.jupiter.api.Test;
/**
*
* Application test
*
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
App.main(new String[]{});
}
}

View File

@ -23,14 +23,15 @@
package com.iluwatar.property;
import org.junit.jupiter.api.Test;
import static com.iluwatar.property.Character.Type;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import org.junit.jupiter.api.Test;
/**
* Date: 12/28/15 - 7:46 PM
*
@ -40,13 +41,13 @@ public class CharacterTest {
@Test
public void testPrototypeStats() throws Exception {
final Character prototype = new Character();
final var prototype = new Character();
for (final Stats stat : Stats.values()) {
for (final var stat : Stats.values()) {
assertFalse(prototype.has(stat));
assertNull(prototype.get(stat));
final Integer expectedValue = stat.ordinal();
final var expectedValue = stat.ordinal();
prototype.set(stat, expectedValue);
assertTrue(prototype.has(stat));
assertEquals(expectedValue, prototype.get(stat));
@ -59,15 +60,13 @@ public class CharacterTest {
}
@Test
public void testCharacterStats() throws Exception {
final Character prototype = new Character();
for (final Stats stat : Stats.values()) {
prototype.set(stat, stat.ordinal());
}
public void testCharacterStats() {
final var prototype = new Character();
Arrays.stream(Stats.values()).forEach(stat -> prototype.set(stat, stat.ordinal()));
final Character mage = new Character(Type.MAGE, prototype);
for (final Stats stat : Stats.values()) {
final Integer expectedValue = stat.ordinal();
final var mage = new Character(Type.MAGE, prototype);
for (final var stat : Stats.values()) {
final var expectedValue = stat.ordinal();
assertTrue(mage.has(stat));
assertEquals(expectedValue, mage.get(stat));
}
@ -75,17 +74,17 @@ public class CharacterTest {
@Test
public void testToString() {
final Character prototype = new Character();
final var prototype = new Character();
prototype.set(Stats.ARMOR, 1);
prototype.set(Stats.AGILITY, 2);
prototype.set(Stats.INTELLECT, 3);
assertEquals("Stats:\n - AGILITY:2\n - ARMOR:1\n - INTELLECT:3\n", prototype.toString());
final Character stupid = new Character(Type.ROGUE, prototype);
final var stupid = new Character(Type.ROGUE, prototype);
stupid.remove(Stats.INTELLECT);
assertEquals("Character type: ROGUE\nStats:\n - AGILITY:2\n - ARMOR:1\n", stupid.toString());
final Character weak = new Character("weak", prototype);
final var weak = new Character("weak", prototype);
weak.remove(Stats.ARMOR);
assertEquals("Player: weak\nStats:\n - AGILITY:2\n - INTELLECT:3\n", weak.toString());
@ -93,32 +92,32 @@ public class CharacterTest {
@Test
public void testName() {
final Character prototype = new Character();
final var prototype = new Character();
prototype.set(Stats.ARMOR, 1);
prototype.set(Stats.INTELLECT, 2);
assertNull(prototype.name());
final Character stupid = new Character(Type.ROGUE, prototype);
final var stupid = new Character(Type.ROGUE, prototype);
stupid.remove(Stats.INTELLECT);
assertNull(stupid.name());
final Character weak = new Character("weak", prototype);
final var weak = new Character("weak", prototype);
weak.remove(Stats.ARMOR);
assertEquals("weak", weak.name());
}
@Test
public void testType() {
final Character prototype = new Character();
final var prototype = new Character();
prototype.set(Stats.ARMOR, 1);
prototype.set(Stats.INTELLECT, 2);
assertNull(prototype.type());
final Character stupid = new Character(Type.ROGUE, prototype);
final var stupid = new Character(Type.ROGUE, prototype);
stupid.remove(Stats.INTELLECT);
assertEquals(Type.ROGUE, stupid.type());
final Character weak = new Character("weak", prototype);
final var weak = new Character("weak", prototype);
weak.remove(Stats.ARMOR);
assertNull(weak.type());
}