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

Remove obsolete catch block in getLayerAs #13091

Merged
merged 1 commit into from
Oct 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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