Skip to content

Commit

Permalink
Deprecated wrongly named methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenni0451 committed Jun 30, 2024
1 parent 2a833ec commit 167fc46
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.lenni0451.commons;

import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.ApiStatus;

@Deprecated
@UtilityClass
@ApiStatus.ScheduledForRemoval
public class StringUtils {

/**
Expand All @@ -13,6 +15,7 @@ public class StringUtils {
* @return The uppercase string
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static String uppercaseFirst(final String s) {
return net.lenni0451.commons.strings.StringUtils.uppercaseFirst(s);
}
Expand All @@ -25,6 +28,7 @@ public static String uppercaseFirst(final String s) {
* @return The repeated string
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static String repeat(final char c, final int count) {
return net.lenni0451.commons.strings.StringUtils.repeat(c, count);
}
Expand All @@ -37,6 +41,7 @@ public static String repeat(final char c, final int count) {
* @return The repeated string
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static String repeat(final String s, final int count) {
return net.lenni0451.commons.strings.StringUtils.repeat(s, count);
}
Expand All @@ -49,6 +54,7 @@ public static String repeat(final String s, final int count) {
* @return The cut string
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static String cut(final String s, final int length) {
return net.lenni0451.commons.strings.StringUtils.cut(s, length);
}
Expand All @@ -62,6 +68,7 @@ public static String cut(final String s, final int length) {
* @return The cut string
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static String cut(String s, final char filler, final int length) {
return net.lenni0451.commons.strings.StringUtils.cut(s, filler, length);
}
Expand All @@ -74,6 +81,7 @@ public static String cut(String s, final char filler, final int length) {
* @return The amount of occurrences
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static int count(final String s, final String toCount) {
return net.lenni0451.commons.strings.StringUtils.count(s, toCount);
}
Expand All @@ -85,6 +93,7 @@ public static int count(final String s, final String toCount) {
* @return The flipped string
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static String flip(final String s) {
return net.lenni0451.commons.strings.StringUtils.flip(s);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.lenni0451.commons.collections;

import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.ApiStatus;

import java.util.*;
import java.util.concurrent.ConcurrentSkipListSet;
Expand Down Expand Up @@ -81,7 +82,7 @@ public static <T extends Set<O>, O> T any(final Supplier<T> setSupplier, final C
* @return The created set
*/
@SafeVarargs
public static <T> HashSet<T> newHashSet(final T... objects) {
public static <T> HashSet<T> hashSet(final T... objects) {
return any(HashSet::new, objects);
}

Expand All @@ -92,7 +93,7 @@ public static <T> HashSet<T> newHashSet(final T... objects) {
* @param <T> The object type
* @return The created set
*/
public static <T> HashSet<T> newHashSet(final Consumer<HashSet<T>> setConsumer) {
public static <T> HashSet<T> hashSet(final Consumer<HashSet<T>> setConsumer) {
return any(HashSet::new, setConsumer);
}

Expand All @@ -104,7 +105,7 @@ public static <T> HashSet<T> newHashSet(final Consumer<HashSet<T>> setConsumer)
* @return The created set
*/
@SafeVarargs
public static <T> LinkedHashSet<T> newLinkedHashSet(final T... objects) {
public static <T> LinkedHashSet<T> linkedHashSet(final T... objects) {
return any(LinkedHashSet::new, objects);
}

Expand All @@ -115,7 +116,7 @@ public static <T> LinkedHashSet<T> newLinkedHashSet(final T... objects) {
* @param <T> The object type
* @return The created set
*/
public static <T> LinkedHashSet<T> newLinkedHashSet(final Consumer<LinkedHashSet<T>> setConsumer) {
public static <T> LinkedHashSet<T> linkedHashSet(final Consumer<LinkedHashSet<T>> setConsumer) {
return any(LinkedHashSet::new, setConsumer);
}

Expand All @@ -127,7 +128,7 @@ public static <T> LinkedHashSet<T> newLinkedHashSet(final Consumer<LinkedHashSet
* @return The created set
*/
@SafeVarargs
public static <T> ConcurrentSkipListSet<T> newConcurrentSkipListSet(final T... objects) {
public static <T> ConcurrentSkipListSet<T> concurrentSkipListSet(final T... objects) {
return any(ConcurrentSkipListSet::new, objects);
}

Expand All @@ -138,8 +139,65 @@ public static <T> ConcurrentSkipListSet<T> newConcurrentSkipListSet(final T... o
* @param <T> The object type
* @return The created set
*/
public static <T> ConcurrentSkipListSet<T> newConcurrentSkipListSet(final Consumer<ConcurrentSkipListSet<T>> setConsumer) {
public static <T> ConcurrentSkipListSet<T> concurrentSkipListSet(final Consumer<ConcurrentSkipListSet<T>> setConsumer) {
return any(ConcurrentSkipListSet::new, setConsumer);
}

/**
* <b>Deprecated</b> - Use {@link #hashSet(Object[])} instead.
*/
@Deprecated
@SafeVarargs
@ApiStatus.ScheduledForRemoval
public static <T> HashSet<T> newHashSet(final T... objects) {
return hashSet(objects);
}

/**
* <b>Deprecated</b> - Use {@link #hashSet(Consumer)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static <T> HashSet<T> newHashSet(final Consumer<HashSet<T>> setConsumer) {
return hashSet(setConsumer);
}

/**
* <b>Deprecated</b> - Use {@link #linkedHashSet(Object[])} instead.
*/
@Deprecated
@SafeVarargs
@ApiStatus.ScheduledForRemoval
public static <T> LinkedHashSet<T> newLinkedHashSet(final T... objects) {
return linkedHashSet(objects);
}

/**
* <b>Deprecated</b> - Use {@link #linkedHashSet(Consumer)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static <T> LinkedHashSet<T> newLinkedHashSet(final Consumer<LinkedHashSet<T>> setConsumer) {
return linkedHashSet(setConsumer);
}

/**
* <b>Deprecated</b> - Use {@link #concurrentSkipListSet(Object[])} instead.
*/
@Deprecated
@SafeVarargs
@ApiStatus.ScheduledForRemoval
public static <T> ConcurrentSkipListSet<T> newConcurrentSkipListSet(final T... objects) {
return concurrentSkipListSet(objects);
}

/**
* <b>Deprecated</b> - Use {@link #concurrentSkipListSet(Consumer)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval
public static <T> ConcurrentSkipListSet<T> newConcurrentSkipListSet(final Consumer<ConcurrentSkipListSet<T>> setConsumer) {
return concurrentSkipListSet(setConsumer);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ void merge() {

@Test
void newHashSet() {
Set<String> set = Sets.newHashSet("A", "B");
Set<String> set = Sets.hashSet("A", "B");
assertInstanceOf(HashSet.class, set);
assertTrue(set.contains("A"));
assertTrue(set.contains("B"));
}

@Test
void newLinkedHashSet() {
Set<String> set = Sets.newLinkedHashSet("A", "B");
Set<String> set = Sets.linkedHashSet("A", "B");
assertInstanceOf(HashSet.class, set);
assertTrue(set.contains("A"));
assertTrue(set.contains("B"));
}

@Test
void newConcurrentSkipListSet() {
Set<String> set = Sets.newConcurrentSkipListSet("A", "B");
Set<String> set = Sets.concurrentSkipListSet("A", "B");
assertInstanceOf(ConcurrentSkipListSet.class, set);
assertTrue(set.contains("A"));
assertTrue(set.contains("B"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DelegateSetTest {

@BeforeEach
void setUp() {
this.set = Sets.newHashSet("Test1", "Test2", "Test3");
this.set = Sets.hashSet("Test1", "Test2", "Test3");
this.delegate = new DelegateSet<>(this.set);
}

Expand Down Expand Up @@ -69,21 +69,21 @@ void remove() {

@Test
void containsAll() {
assertEquals(this.set.containsAll(Sets.newHashSet("Test1", "Test2")), this.delegate.containsAll(Sets.newHashSet("Test1", "Test2")));
assertEquals(this.set.containsAll(Sets.newHashSet("Test1", "Test10")), this.delegate.containsAll(Sets.newHashSet("Test1", "Test10")));
assertEquals(this.set.containsAll(Sets.hashSet("Test1", "Test2")), this.delegate.containsAll(Sets.hashSet("Test1", "Test2")));
assertEquals(this.set.containsAll(Sets.hashSet("Test1", "Test10")), this.delegate.containsAll(Sets.hashSet("Test1", "Test10")));
}

@Test
void addAll() {
this.delegate.addAll(Sets.newHashSet("Test4", "Test5"));
this.delegate.addAll(Sets.hashSet("Test4", "Test5"));
assertEquals(this.set.size(), this.delegate.size());
assertEquals(this.set.contains("Test4"), this.delegate.contains("Test4"));
assertEquals(this.set.contains("Test5"), this.delegate.contains("Test5"));
}

@Test
void retainAll() {
this.delegate.retainAll(Sets.newHashSet("Test1", "Test2"));
this.delegate.retainAll(Sets.hashSet("Test1", "Test2"));
assertEquals(this.set.size(), this.delegate.size());
assertEquals(this.set.contains("Test1"), this.delegate.contains("Test1"));
assertEquals(this.set.contains("Test2"), this.delegate.contains("Test2"));
Expand All @@ -92,7 +92,7 @@ void retainAll() {

@Test
void removeAll() {
this.delegate.removeAll(Sets.newHashSet("Test1", "Test2"));
this.delegate.removeAll(Sets.hashSet("Test1", "Test2"));
assertEquals(this.set.size(), this.delegate.size());
assertEquals(this.set.contains("Test1"), this.delegate.contains("Test1"));
assertEquals(this.set.contains("Test2"), this.delegate.contains("Test2"));
Expand Down

0 comments on commit 167fc46

Please sign in to comment.