I need to convert the following java method to scala and am having difficulty because scala doesn't allow you to return values in the middle of methods. Could someone give me a hand or at least a start on how to convert this:
public boolean isAllowed(String method, String path, Map<String,String> apiUrlMap) {
if (apiUrlMap != null) {
Set<Entry<String, String>> apiSet = apiUrlMap.entrySet();
for (Entry<String, String> apiUrl : apiSet) {
String aUrl = apiUrl.getKey();
String aMeth = apiUrl.getValue();
if (aUrl.equals("#")) {
if (aMeth.contains(method)) {
return true;
}
}
if (aUrl.endsWith("#")) {
String testUrl = aUrl.replaceFirst("/#", "");
if (path.startsWith(testUrl)) {
if (aMeth.contains(method)) {
return true;
}
}
}
if (aUrl.equals(path) || path.equals(aUrl +"/")) {
if (aMeth.contains(method)) {
return true;
}
}
}
}
return false;
}
returnkeyword also exists in Scala.