Skip to content

Commit

Permalink
@SuppressWarnings("unchecked") at the smaller scope
Browse files Browse the repository at this point in the history
  • Loading branch information
timzam committed Sep 11, 2017
1 parent 8a0ce25 commit 5d49860
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ public boolean test(HasVisibility value) {
}
};

@SuppressWarnings("unchecked")
public static <HasParentT extends HasParent<HasParentT> & HasFocusability> Predicate<HasParentT> isFocusable() {
return (Predicate<HasParentT>) IS_FOCUSABLE;
@SuppressWarnings("unchecked")
Predicate<HasParentT> predicate = (Predicate<HasParentT>) IS_FOCUSABLE;
return predicate;
}

@SuppressWarnings("unchecked")
public static <HasParentT extends HasParent<HasParentT> & HasVisibility> Predicate<HasParentT> isInvisible() {
return (Predicate<HasParentT>) IS_INVISIBLE;
@SuppressWarnings("unchecked")
Predicate<HasParentT> predicate = (Predicate<HasParentT>) IS_INVISIBLE;
return predicate;
}

public static <CompositeT extends Composite<CompositeT>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ private void testNonListened(Property<Boolean> src,
assertEquals(0, res.size());
}

@SuppressWarnings("unchecked")
private void testListened(Property<Boolean> src,
ObservableCollection<String> selected, ObservableCollection<String> res) {
@SuppressWarnings("unchecked")
CollectionListener<String> mock = mock(CollectionListener.class);
res.addListener(mock);

Expand All @@ -223,12 +223,12 @@ private void testListened(Property<Boolean> src,
assertEquals(0, res.size());
}

@SuppressWarnings("unchecked")
private void testRegistrations(Property<Boolean> src, ObservableCollection<String> res,
AtomicInteger propertyListeners, AtomicInteger collectionListeners) {
assertEquals(0, propertyListeners.get());
assertEquals(0, collectionListeners.get());

@SuppressWarnings("unchecked")
CollectionListener<String> mock = mock(CollectionListener.class);
Registration mockReg = res.addListener(mock);
assertEquals(1, propertyListeners.get());
Expand Down
25 changes: 15 additions & 10 deletions util/base/src/main/java/jetbrains/jetpad/base/Functions.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ public static <ItemT> Supplier<ItemT> memorize(Supplier<ItemT> supplier) {
return new Memo<>(supplier);
}

@SuppressWarnings("unchecked")
public static <ArgT> Predicate<ArgT> alwaysTrue() {
return (Predicate<ArgT>) TRUE_PREDICATE;
@SuppressWarnings("unchecked")
Predicate<ArgT> predicate = (Predicate<ArgT>) TRUE_PREDICATE;
return predicate;
}

@SuppressWarnings("unchecked")
public static <ArgT> Predicate<ArgT> alwaysFalse() {
return (Predicate<ArgT>) FALSE_PREDICATE;
@SuppressWarnings("unchecked")
Predicate<ArgT> predicate = (Predicate<ArgT>) FALSE_PREDICATE;
return predicate;
}

public static <ArgT, ResultT> Function<ArgT, ResultT> constant(final ResultT result) {
Expand All @@ -85,19 +87,22 @@ public ResultT apply(ArgT a) {
};
}

@SuppressWarnings("unchecked")
public static <ArgT> Predicate<ArgT> isNull() {
return (Predicate<ArgT>) NULL_PREDICATE;
@SuppressWarnings("unchecked")
Predicate<ArgT> predicate = (Predicate<ArgT>) NULL_PREDICATE;
return predicate;
}

@SuppressWarnings("unchecked")
public static <ArgT> Predicate<ArgT> isNotNull() {
return (Predicate<ArgT>) NOT_NULL_PREDICATE;
@SuppressWarnings("unchecked")
Predicate<ArgT> predicate = (Predicate<ArgT>) NOT_NULL_PREDICATE;
return predicate;
}

@SuppressWarnings("unchecked")
public static <ValueT> Function<ValueT, ValueT> identity() {
return (Function<ValueT, ValueT>) IDENTITY_FUNCTION;
@SuppressWarnings("unchecked")
Function<ValueT, ValueT> function = (Function<ValueT, ValueT>) IDENTITY_FUNCTION;
return function;
}

public static <ValueT> Predicate<ValueT> same(final Object value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public final class Functions {

private Functions() { }

@SuppressWarnings("unchecked")
public static <ArgT> Predicate<ArgT> alwaysTrue() {
return (Predicate<ArgT>) TRUE_PREDICATE;
@SuppressWarnings("unchecked")
Predicate<ArgT> predicate = (Predicate<ArgT>) TRUE_PREDICATE;
return predicate;
}

@SuppressWarnings("unchecked")
public static <ArgT> Predicate<ArgT> alwaysFalse() {
return (Predicate<ArgT>) FALSE_PREDICATE;
@SuppressWarnings("unchecked")
Predicate<ArgT> predicate = (Predicate<ArgT>) FALSE_PREDICATE;
return predicate;
}
}

0 comments on commit 5d49860

Please sign in to comment.