Sfoglia il codice sorgente

Adds default getNumberOfRoles to Protocol Interface

Andreas T. Meyer-Berg 6 anni fa
parent
commit
b983762f93

+ 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