package org.springframework.roo.addon.web.mvc.thymeleaf.addon;
import static org.springframework.roo.model.SpringJavaType.DELETE_MAPPING;
import static org.springframework.roo.model.SpringJavaType.GET_MAPPING;
import static org.springframework.roo.model.SpringJavaType.INIT_BINDER;
import static org.springframework.roo.model.SpringJavaType.MODEL;
import static org.springframework.roo.model.SpringJavaType.MODEL_AND_VIEW;
import static org.springframework.roo.model.SpringJavaType.POST_MAPPING;
import static org.springframework.roo.model.SpringJavaType.REQUEST_PARAM;
import static org.springframework.roo.model.SpringJavaType.RESPONSE_ENTITY;
import static org.springframework.roo.model.SpringletsJavaType.SPRINGLETS_DATATABLES;
import static org.springframework.roo.model.SpringletsJavaType.SPRINGLETS_GLOBAL_SEARCH;
import static org.springframework.roo.model.SpringletsJavaType.SPRINGLETS_NOT_FOUND_EXCEPTION;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.tuple.Pair;
import org.jsoup.helper.Validate;
import org.springframework.roo.addon.jpa.addon.entity.JpaEntityMetadata;
import org.springframework.roo.addon.jpa.addon.entity.JpaEntityMetadata.RelationInfo;
import org.springframework.roo.addon.jpa.annotations.entity.JpaRelationType;
import org.springframework.roo.addon.layers.service.addon.ServiceMetadata;
import org.springframework.roo.addon.web.mvc.controller.addon.ControllerMetadata;
import org.springframework.roo.addon.web.mvc.controller.addon.RelationInfoExtended;
import org.springframework.roo.addon.web.mvc.controller.annotations.ControllerType;
import org.springframework.roo.addon.web.mvc.thymeleaf.annotations.RooThymeleaf;
import org.springframework.roo.addon.web.mvc.views.AbstractViewMetadata;
import org.springframework.roo.classpath.PhysicalTypeIdentifier;
import org.springframework.roo.classpath.PhysicalTypeIdentifierNamingUtils;
import org.springframework.roo.classpath.PhysicalTypeMetadata;
import org.springframework.roo.classpath.details.ClassOrInterfaceTypeDetails;
import org.springframework.roo.classpath.details.ConstructorMetadata;
import org.springframework.roo.classpath.details.ConstructorMetadataBuilder;
import org.springframework.roo.classpath.details.FieldMetadata;
import org.springframework.roo.classpath.details.FieldMetadataBuilder;
import org.springframework.roo.classpath.details.MethodMetadata;
import org.springframework.roo.classpath.details.MethodMetadataBuilder;
import org.springframework.roo.classpath.details.annotations.AnnotatedJavaType;
import org.springframework.roo.classpath.details.annotations.AnnotationAttributeValue;
import org.springframework.roo.classpath.details.annotations.AnnotationMetadata;
import org.springframework.roo.classpath.details.annotations.AnnotationMetadataBuilder;
import org.springframework.roo.classpath.details.comments.CommentStructure;
import org.springframework.roo.classpath.details.comments.CommentStructure.CommentLocation;
import org.springframework.roo.classpath.details.comments.JavadocComment;
import org.springframework.roo.classpath.itd.InvocableMemberBodyBuilder;
import org.springframework.roo.metadata.MetadataIdentificationUtils;
import org.springframework.roo.model.DataType;
import org.springframework.roo.model.JavaSymbolName;
import org.springframework.roo.model.JavaType;
import org.springframework.roo.model.JdkJavaType;
import org.springframework.roo.model.Jsr303JavaType;
import org.springframework.roo.model.SpringEnumDetails;
import org.springframework.roo.model.SpringJavaType;
import org.springframework.roo.model.SpringletsJavaType;
import org.springframework.roo.project.LogicalPath;
/**
* Metadata for {@link RooThymeleaf}.
*
* @author Juan Carlos García
* @author Jose Manuel Vivó
* @author Sergio Clares
* @author Fran Cardoso
* @since 2.0
*/
public class ThymeleafMetadata extends AbstractViewMetadata {
// Method names
protected static final JavaSymbolName CREATE_METHOD_NAME = new JavaSymbolName("create");
protected static final JavaSymbolName LIST_METHOD_NAME = new JavaSymbolName("list");
protected static final JavaSymbolName DELETE_METHOD_NAME = new JavaSymbolName("delete");
protected static final JavaSymbolName DELETE_BATCH_METHOD_NAME =
new JavaSymbolName("deleteBatch");
protected static final JavaSymbolName LIST_URI_METHOD_NAME = new JavaSymbolName("listURI");
protected static final JavaSymbolName LIST_DATATABLES_METHOD_NAME = new JavaSymbolName(
"datatables");
protected static final JavaSymbolName LIST_DATATABLES_BY_IDS_IN_METHOD_NAME = new JavaSymbolName(
"datatablesByIdsIn");
protected static final JavaSymbolName LIST_DATATABLES_DETAILS_METHOD_NAME = new JavaSymbolName(
"datatables");
protected static final JavaSymbolName LIST_DATATABLES_BY_IDS_IN_DETAILS_METHOD_NAME =
new JavaSymbolName("datatablesByIdsIn");
protected static final JavaSymbolName SELECT2_METHOD_NAME = new JavaSymbolName("select2");
protected static final JavaSymbolName SHOW_URI_METHOD_NAME = new JavaSymbolName("showURI");
protected static final JavaSymbolName SHOW_METHOD_NAME = new JavaSymbolName("show");
protected static final JavaSymbolName SHOW_INLINE_METHOD_NAME = new JavaSymbolName("showInline");
protected static final JavaSymbolName CREATE_FORM_METHOD_NAME = new JavaSymbolName("createForm");
protected static final JavaSymbolName EDIT_FORM_METHOD_NAME = new JavaSymbolName("editForm");
protected static final JavaSymbolName UPDATE_METHOD_NAME = new JavaSymbolName("update");
protected static final JavaSymbolName GET_MODEL_NAME_METHOD_NAME = new JavaSymbolName(
"getModelName");
protected static final JavaSymbolName GET_EDIT_VIEW_PATH_METHOD_NAME = new JavaSymbolName(
"getEditViewPath");
protected static final JavaSymbolName GET_LAST_VERSION_METHOD_NAME = new JavaSymbolName(
"getLastVersion");
protected static final JavaSymbolName POPULATE_AND_GET_FORM_VIEW_METHOD_NAME =
new JavaSymbolName("populateAndGetFormView");
protected static final JavaSymbolName EXPORT_METHOD_NAME = new JavaSymbolName("export");
protected static final JavaSymbolName EXPORT_CSV_METHOD_NAME = new JavaSymbolName("exportCsv");
protected static final JavaSymbolName EXPORT_PDF_METHOD_NAME = new JavaSymbolName("exportPdf");
protected static final JavaSymbolName EXPORT_XLS_METHOD_NAME = new JavaSymbolName("exportXls");
protected static final JavaSymbolName ADD_COLUMN_TO_REPORT_BUILDER_METHOD_NAME =
new JavaSymbolName("addColumnToReportBuilder");
protected static final JavaSymbolName FIN_ONE_FOR_UPDATE_METHOD_NAME = new JavaSymbolName(
"findOneForUpdate");
private static final AnnotatedJavaType PAGEABLE_PARAM = new AnnotatedJavaType(
SpringJavaType.PAGEABLE);
private static final JavaSymbolName PAGEABLE_PARAM_NAME = new JavaSymbolName("pageable");
private static final AnnotatedJavaType DATATABLES_PAGEABLE_PARAM = new AnnotatedJavaType(
SpringletsJavaType.SPRINGLETS_DATATABLES_PAGEABLE);
private static final JavaSymbolName DATATABLES_PAGEABLE_PARAM_NAME = new JavaSymbolName(
"pageable");
private static final AnnotatedJavaType GLOBAL_SEARCH_PARAM = new AnnotatedJavaType(
SPRINGLETS_GLOBAL_SEARCH);
private static final JavaSymbolName GLOBAL_SEARCH_PARAM_NAME = new JavaSymbolName("search");
private static final AnnotatedJavaType MODEL_PARAM = new AnnotatedJavaType(SpringJavaType.MODEL);
private static final JavaSymbolName MODEL_PARAM_NAME = new JavaSymbolName("model");
private static final JavaSymbolName FORM_BEAN_PARAM_NAME = new JavaSymbolName("formBean");
private