Skip to content

Commit

Permalink
Add generic type variable bound to JsonRightPadded<T> (#4147)
Browse files Browse the repository at this point in the history
Changes `<T>` to `<T extends Json>` as that is the only way it is currently being used.

Note: In the `J` model the padding constructs are also used to wrap non-`Tree` elements, but not in `Json`.
  • Loading branch information
knutwannheden authored Apr 24, 2024
1 parent addfc0c commit 12ead86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Space visitSpace(Space space, P p) {
}

@SuppressWarnings("ConstantConditions")
public <T> JsonRightPadded<T> visitRightPadded(@Nullable JsonRightPadded<T> right, P p) {
public <T extends Json> JsonRightPadded<T> visitRightPadded(@Nullable JsonRightPadded<T> right, P p) {
if (right == null) {
//noinspection ConstantConditions
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
@Data
public class JsonRightPadded<T> {
public class JsonRightPadded<T extends Json> {
@With
T element;

Expand All @@ -52,7 +52,7 @@ public JsonRightPadded<T> map(UnaryOperator<T> map) {
return withElement(map.apply(element));
}

public static <T> List<T> getElements(List<JsonRightPadded<T>> ls) {
public static <T extends Json> List<T> getElements(List<JsonRightPadded<T>> ls) {
List<T> list = new ArrayList<>();
for (JsonRightPadded<T> l : ls) {
T elem = l.getElement();
Expand Down Expand Up @@ -92,7 +92,7 @@ public static <J2 extends Json> List<JsonRightPadded<J2>> withElements(List<Json
return after;
}

public static <T> JsonRightPadded<T> build(T element) {
public static <T extends Json> JsonRightPadded<T> build(T element) {
return new JsonRightPadded<>(element, Space.EMPTY, Markers.EMPTY);
}

Expand Down

0 comments on commit 12ead86

Please sign in to comment.