/*******************************************************************************
 * DIANNE  - Framework for distributed artificial neural networks
 * Copyright (C) 2015  iMinds - IBCN - UGent
 *
 * This file is part of DIANNE.
 *
 * DIANNE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contributors:
 *     Tim Verbelen, Steven Bohez
 *******************************************************************************/
package be.iminds.iot.dianne.api.nn.module.dto;

import java.util.Map;
import java.util.UUID;

/**
 * Represents a single Module of a Neural Network.
 * 
 * @author tverbele
 *
 */
public class ModuleDTO {

	// UUID of this Module
	public final UUID id;
	
	// Type of this Module
	//  this maps to a ModuleTypeDTO, is used by a factory 
	//  to create an instance of this Module
	public String type;
	
	// UUID(s) of the next Modules in the neural network
	public UUID[] next;
	// UUID(s) of the previous Modules in the neural network
	public UUID[] prev;
	
	// Specific properties for this Module
	public Map<String, String> properties;

	
	public ModuleDTO(UUID id, String type, 
			UUID[] next, UUID[] prev, 
			Map<String, String> properties){
		this.id = id;
		this.type = type;
		this.next = next;
		this.prev = prev;
		this.properties = properties;
	}
	
	@Override
	public boolean equals(Object o){
		if(!(o instanceof ModuleDTO)){
			return false;
		}
		
		ModuleDTO other = (ModuleDTO) o;
		return other.id.equals(id);
	}
	
	@Override
	public int hashCode(){
		return id.hashCode();
	}
}

@@ -1069,16 +1069,42 @@
 e.dto;%0A%0A
+import java.util.HashMap;%0A
 import j
@@ -1113,24 +1113,24 @@
 a.util.Map;%0A
-
 import java.
@@ -1685,16 +1685,111 @@
 rties;%0A%0A
+%09%0A%09public ModuleDTO() %7B%0A%09%09this.id = UUID.randomUUID();%0A%09%09this.properties = new HashMap%3C%3E();%0A%09%7D%0A
 %09%0A%09publi
@@ -2209,16 +2209,16 @@
 Code()%7B%0A
-
 %09%09return
@@ -2236,10 +2236,91 @@
 e();%0A%09%7D%0A
+%09%0A%09@Override%0A%09public String toString() %7B%0A%09%09return id.toString()+%22(%22+type+%22)%22;%0A%09%7D%0A
 %7D%0A

add no-arg constructor for ModuleDTO to facilitate writing importer