浏览代码

Adds default getNumberOfRoles to Protocol Interface

Andreas T. Meyer-Berg 6 年之前
父节点
当前提交
b983762f93
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/Protocol.java

+ 3 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/Protocol.java

@@ -50,7 +50,9 @@ public interface Protocol {
 	 * 
 	 * @return number of different roles
 	 */
-	public int getNumberOfRoles();
+	public default int getNumberOfRoles(){
+		return getRoles() == null ? 0 : getRoles().length;
+	}
 
 	/**
 	 * Returns the textual representation of the different Roles. The Array