3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

CappedSet.newCappedSet() -> CappedSet.create()

Dieser Commit ist enthalten in:
Andrew Steinborn 2019-05-14 04:11:49 -04:00
Ursprung 57085feb42
Commit 5bd9f0a96f
3 geänderte Dateien mit 5 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -108,7 +108,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
this.virtualHost = virtualHost; this.virtualHost = virtualHost;
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED; this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
this.connectionPhase = minecraftConnection.getType().getInitialClientPhase(); this.connectionPhase = minecraftConnection.getType().getInitialClientPhase();
this.knownChannels = CappedSet.newCappedSet(MAX_PLUGIN_CHANNELS); this.knownChannels = CappedSet.create(MAX_PLUGIN_CHANNELS);
} }
@Override @Override

Datei anzeigen

@ -26,7 +26,7 @@ public class CappedSet<T> extends ForwardingSet<T> {
* @param <T> the type of elements in the collection * @param <T> the type of elements in the collection
* @return the new collection * @return the new collection
*/ */
public static <T> Set<T> newCappedSet(int maxSize) { public static <T> Set<T> create(int maxSize) {
return new CappedSet<>(new HashSet<>(), maxSize); return new CappedSet<>(new HashSet<>(), maxSize);
} }

Datei anzeigen

@ -14,7 +14,7 @@ class CappedSetTest {
@Test @Test
void basicVerification() { void basicVerification() {
Collection<String> coll = CappedSet.newCappedSet(1); Collection<String> coll = CappedSet.create(1);
assertTrue(coll.add("coffee"), "did not add single item"); assertTrue(coll.add("coffee"), "did not add single item");
assertThrows(IllegalStateException.class, () -> coll.add("tea"), assertThrows(IllegalStateException.class, () -> coll.add("tea"),
"item was added to collection although it is too full"); "item was added to collection although it is too full");
@ -27,7 +27,7 @@ class CappedSetTest {
Set<String> doesFill2 = ImmutableSet.of("chocolate"); Set<String> doesFill2 = ImmutableSet.of("chocolate");
Set<String> overfill = ImmutableSet.of("Coke", "Pepsi"); Set<String> overfill = ImmutableSet.of("Coke", "Pepsi");
Collection<String> coll = CappedSet.newCappedSet(3); Collection<String> coll = CappedSet.create(3);
assertTrue(coll.addAll(doesFill1), "did not add items"); assertTrue(coll.addAll(doesFill1), "did not add items");
assertTrue(coll.addAll(doesFill2), "did not add items"); assertTrue(coll.addAll(doesFill2), "did not add items");
assertThrows(IllegalStateException.class, () -> coll.addAll(overfill), assertThrows(IllegalStateException.class, () -> coll.addAll(overfill),
@ -41,7 +41,7 @@ class CappedSetTest {
Set<String> doesFill2 = ImmutableSet.of("coffee", "chocolate"); Set<String> doesFill2 = ImmutableSet.of("coffee", "chocolate");
Set<String> overfill = ImmutableSet.of("coffee", "Coke", "Pepsi"); Set<String> overfill = ImmutableSet.of("coffee", "Coke", "Pepsi");
Collection<String> coll = CappedSet.newCappedSet(3); Collection<String> coll = CappedSet.create(3);
assertTrue(coll.addAll(doesFill1), "did not add items"); assertTrue(coll.addAll(doesFill1), "did not add items");
assertTrue(coll.addAll(doesFill2), "did not add items"); assertTrue(coll.addAll(doesFill2), "did not add items");
assertThrows(IllegalStateException.class, () -> coll.addAll(overfill), assertThrows(IllegalStateException.class, () -> coll.addAll(overfill),