Skip to content

Commit

Permalink
Fixed some nullability annotations in StaticImports to work with Kotl…
Browse files Browse the repository at this point in the history
…in 1.4.21.
  • Loading branch information
GlenKPeterson committed Dec 7, 2020
1 parent de98375 commit de2053c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ releases on the way from an old version to a new one. Fix any deprecation warni
release before upgrading to the next one. The documentation next to each Deprecated annotation
tells you what to use instead. Once we delete the deprecated methods, that documentation goes too.

## Release 3.5.9 2020-12-07
- Fixed some nullability annotations in StaticImports to work with Kotlin 1.4.21.

## Release 3.5.8 2020-10-06
- Renamed all mutable collections from Mutable___ to Mut___ so they no longer conflict with Kotlin's StdLib.
See script below to help you upgrade.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ http://mvnrepository.com/artifact/org.organicdesign/Paguro
-->
<groupId>org.organicdesign</groupId>
<artifactId>Paguro</artifactId>
<version>3.5.8</version>
<version>3.5.9</version>
<packaging>jar</packaging>

<name>Paguro</name>
Expand Down
36 changes: 20 additions & 16 deletions src/main/java/org/organicdesign/fp/StaticImports.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ inserts, then the RRB tree get() method may be about 5x slower. Otherwise, perf
This data definition method is one of the few methods in this project that support varargs.
*/
@SafeVarargs
public static <T> @NotNull MutRrbt<@Nullable T> mutableRrb(@Nullable T... items) {
public static <T> @NotNull MutRrbt<T> mutableRrb(T... items) {
if ( (items == null) || (items.length < 1) ) { return RrbTree.emptyMutable(); }
return RrbTree.<@Nullable T>emptyMutable()
return RrbTree.<T>emptyMutable()
.concat(Arrays.asList(items));
}

Expand All @@ -146,10 +146,10 @@ inserts, then the RRB tree get() method may be about 5x slower. Otherwise, perf
values overwrite earlier ones.
*/
@SafeVarargs
public static <T> @NotNull MutSet<@Nullable T> mutableSet(@Nullable T... items) {
MutSet<@Nullable T> ret = PersistentHashSet.emptyMutable();
public static <T> @NotNull MutSet<T> mutableSet(T... items) {
MutSet<T> ret = PersistentHashSet.emptyMutable();
if (items == null) { return ret; }
for (@Nullable T t : items) {
for (T t : items) {
ret.put(t);
}
return ret;
Expand All @@ -160,10 +160,10 @@ inserts, then the RRB tree get() method may be about 5x slower. Otherwise, perf
few methods in this project that support varargs.
*/
@SafeVarargs
public static <T> @NotNull MutList<@Nullable T> mutableVec(@Nullable T... items) {
MutList<@Nullable T> ret = PersistentVector.emptyMutable();
public static <T> @NotNull MutList<T> mutableVec(T... items) {
MutList<T> ret = PersistentVector.emptyMutable();
if (items == null) { return ret; }
for (@Nullable T t : items) {
for (T t : items) {
ret.append(t);
}
return ret;
Expand All @@ -179,7 +179,7 @@ inserts, then the RRB tree get() method may be about 5x slower. Otherwise, perf
This data definition method is one of the few methods in this project that support varargs.
*/
@SafeVarargs
static public <T> @NotNull ImRrbt<@Nullable T> rrb(@Nullable T... items) {
static public <T> @NotNull ImRrbt<T> rrb(T... items) {
if ( (items == null) || (items.length < 1) ) { return RrbTree.empty(); }
return mutableRrb(items).immutable();
}
Expand All @@ -190,7 +190,7 @@ inserts, then the RRB tree get() method may be about 5x slower. Otherwise, perf
values overwrite earlier ones.
*/
@SafeVarargs
public static <T> @NotNull ImSet<@Nullable T> set(@Nullable T... items) {
public static <T> @NotNull ImSet<T> set(T... items) {
if ( (items == null) || (items.length < 1) ) { return PersistentHashSet.empty(); }
return PersistentHashSet.of(Arrays.asList(items));
}
Expand Down Expand Up @@ -258,7 +258,7 @@ becomes part of the set (it's not for pre-sorting).
few methods in this project that support varargs.
*/
@SafeVarargs
static public <T> @NotNull ImList<@Nullable T> vec(@Nullable T... items) {
static public <T> @NotNull ImList<T> vec(T... items) {
if ( (items == null) || (items.length < 1) ) { return PersistentVector.empty(); }
return mutableVec(items).immutable();
}
Expand Down Expand Up @@ -289,14 +289,18 @@ becomes part of the set (it's not for pre-sorting).
/** Wrap a String (or CharSequence) to perform a Character-by-Character transformation on it. */
public static @NotNull UnmodIterable<Character> xformChars(CharSequence seq) {
//noinspection Convert2Lambda
return new UnmodIterable<Character>() {
return new UnmodIterable<>() {
@NotNull
@Override public UnmodIterator<Character> iterator() {
return new UnmodIterator<Character>() {
@Override
public UnmodIterator<Character> iterator() {
return new UnmodIterator<>() {
private int idx = 0;
@Override public boolean hasNext() { return idx < seq.length(); }

@Override public Character next() {
@Override
public boolean hasNext() { return idx < seq.length(); }

@Override
public Character next() {
int nextIdx = idx + 1;
Character c = seq.charAt(idx);
idx = nextIdx;
Expand Down

0 comments on commit de2053c

Please sign in to comment.