Skip to content

Commit

Permalink
get rid of a raw type
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Dec 21, 2024
1 parent 07ecda3 commit a61a738
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 @@ -121,17 +121,18 @@ public final <T> void setListeners(EventType<T> type, Class<? extends T>... list
setListeners( type, resolveListenerInstances( type, listenerClasses ) );
}

@SuppressWarnings( {"unchecked"})
@SafeVarargs
private <T> T[] resolveListenerInstances(EventType<T> type, Class<? extends T>... listenerClasses) {
@SuppressWarnings("unchecked")
T[] listeners = (T[]) Array.newInstance( type.baseListenerInterface(), listenerClasses.length );
for ( int i = 0; i < listenerClasses.length; i++ ) {
listeners[i] = resolveListenerInstance( listenerClasses[i] );
}
return listeners;
}

@SuppressWarnings( {"unchecked"})
private <T> T resolveListenerInstance(Class<T> listenerClass) {
@SuppressWarnings("unchecked")
T listenerInstance = (T) listenerClassToInstanceMap.get( listenerClass );
if ( listenerInstance == null ) {
listenerInstance = instantiateListener( listenerClass );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ public String eventName() {
return eventName;
}

@SuppressWarnings("rawtypes")
public Class baseListenerInterface() {
public Class<T> baseListenerInterface() {
return baseListenerInterface;
}

Expand Down

0 comments on commit a61a738

Please sign in to comment.