Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - remove obsolete catch block in getLayerAs
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Oct 15, 2018
1 parent ecb59bf commit 787bbdf
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,16 @@ public Layer getLayer(@NonNull String layerId) {
}

/**
* Tries to cast the Layer to T, returns null if it's another type.
* Tries to cast the Layer to T, throws ClassCastException if it's another type.
*
* @param layerId the layer id used to look up a layer
* @param <T> the generic attribute of a Layer
* @return the casted Layer, null if another type
*/
@Nullable
public <T extends Layer> T getLayerAs(@NonNull String layerId) {
try {
// noinspection unchecked
return (T) nativeMapView.getLayer(layerId);
} catch (ClassCastException exception) {
String message = String.format("Layer: %s is a different type: ", layerId);
Logger.e(TAG, message, exception);
MapStrictMode.strictModeViolation(message, exception);
return null;
}
// noinspection unchecked
return (T) nativeMapView.getLayer(layerId);
}

/**
Expand Down

0 comments on commit 787bbdf

Please sign in to comment.