//
// https://www.ramecera.it/myscrewdriver.html
// e-mail: screwdriver@ramecera.it
//
/* This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License v1.0 which accompanies this
 * distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html */
package it.ramecera.screwdriver.outfits;

import java.util.ArrayList;
import java.util.List;

import it.ramecera.salad.everyday.Candies;

/**
 * <p>
 * Elements forming a method described in the ele file.
 * </p>
 * <p>
 * Company: Ramecera™<br>
 * Creation date: 2020-04-09<br>
 * Last updated: 2020-08-03
 * </p>
 * <p>
 * Modifications:<br>
 * </p>
 * 
 * @author M. Maglioni */
final public class ELEMethod {

	/** name of the method */
	public String name;
	/** the java source code */
	public String source;
	/** method DAO arguments, type + object */
	public String upperArguments;
	/** method DAO arguments, object only */
	public String lowerArguments;

	/** the list of DB tables involved in the method */
	public List<TableOutfit> tableE = new ArrayList<TableOutfit>();

	/** the list of classes of the topic objects of the method */
	public List<String> classE = new ArrayList<String>();

	/** default constructor */
	public ELEMethod() {

	}

	/**
	 * <p>
	 * Classic constructor.
	 * </p>
	 * <p>
	 * Creation date: 2020-04-09<br>
	 * Last updated: 2020-04-09
	 * </p>
	 * <p>
	 * Modifications:<br>
	 * </p>
	 * 
	 * @param name method name
	 * @param sorgente java source code
	 * @param upperArguments method arguments, type + object
	 * @param lowerArguments method arguments, only object
	 * @param tableE list of DB tables involved in the method
	 * @param classE list of types, optional, after the list of DAOs */
	public ELEMethod(final String name, final String sorgente,
			final String upperArguments, final String lowerArguments,
			List<TableOutfit> tableE, List<String> classE) {
		super();
		this.name = name;
		this.source = sorgente;
		this.upperArguments = upperArguments;
		this.lowerArguments = lowerArguments;
		this.tableE = tableE;
		this.classE = classE;
	}

	/**
	 * <p>
	 * Classic toString method.
	 * </p>
	 * <p>
	 * Creation date: 2020-04-09<br>
	 * Last updated: 2020-04-09
	 * </p>
	 * <p>
	 * Modifications:<br>
	 * </p>
	 * 
	 * @return the compound string */
	public String toString() {
		String s = "";
		s += "********************" + Candies.LF;
		s += "Method «" + name + "»" + Candies.LF + Candies.LF;
		if (tableE.size() > 0) {
			s += "Tables: ";
			for (TableOutfit t : tableE) {
				s += t.entityName + ", ";
			}
			/* I cut the last 2 characters */
			s = s.substring(0, s.length() - 2);
			s += Candies.LF;
		}
		if (upperArguments != null) {
			s += "Arguments with uppercase char.: " + upperArguments
					+ Candies.LF;
		}
		if (lowerArguments != null) {
			s += "Arguments with lowercase char.: " + lowerArguments
					+ Candies.LF;
		}
		if (source != null) {
			s += Candies.LF + "Source code:" + Candies.LF;
			s += source + Candies.LF;
		}
		s += "********************" + Candies.LF;
		return s;
	}
}
