Example usage for org.apache.commons.lang3 StringUtils capitalize

List of usage examples for org.apache.commons.lang3 StringUtils capitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils capitalize.

Prototype

public static String capitalize(final String str) 

Source Link

Document

Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .

Usage

From source file:org.gerzog.spock.injectmock.internal.accessors.MethodAccessor.java

private static String toMethodName(final String propertyName) {
    return SETTER_PREFIX + StringUtils.capitalize(propertyName);
}

From source file:org.graylog.plugins.pipelineprocessor.functions.strings.Capitalize.java

@Override
protected String apply(String value, Locale unused) {
    return StringUtils.capitalize(value);
}

From source file:org.grible.adaptor.TestTable.java

private HashMap<String, String> getOneRowTable(String subTableType) {
    HashMap<String, String> result = new HashMap<String, String>();
    try {//w  w w . j av  a  2  s  .c o  m
        if (GribleSettings.getAppType() == AppTypes.POSTGRESQL) {
            Connection conn = getConnection();
            Statement stmt = conn.createStatement();

            String strKeys = null;
            String strValues = null;

            ResultSet rs = stmt.executeQuery("SELECT t.keys, t.values " + "FROM tables t "
                    + "INNER JOIN tabletypes tt ON t.type = tt.id "
                    + "INNER JOIN tables pt ON t.parentid=pt.id "
                    + "INNER JOIN categories c ON pt.categoryid=c.id "
                    + "INNER JOIN products p ON c.productid=p.id "
                    + "INNER JOIN tabletypes ctt ON c.type = ctt.id " + "WHERE tt.name='" + subTableType
                    + "' AND pt.name='" + tableName + "' AND p.name='" + productName
                    + "' AND ctt.name='table'");
            if (rs.next()) {
                strKeys = rs.getString("keys");
                strValues = rs.getString("values");
            }

            conn.close();
            rs.close();
            stmt.close();

            if (strKeys != null && strValues != null) {
                Gson gson = new Gson();
                Key[] keys = gson.fromJson(strKeys, Key[].class);
                String[][] values = gson.fromJson(strValues, String[][].class);
                for (int j = 0; j < values[0].length; j++) {
                    result.put(keys[j].getName(), values[0][j].replace("\\", File.separator));
                }
            } else {
                throw new Exception(StringUtils.capitalize(subTableType) + "s in the table '" + tableName
                        + "' of product '" + productName + "' not found.");
            }
        } else {
            String fileName = tableName + "_" + subTableType.toUpperCase() + ".json";
            File file = IOHelper.searchFile(new File(productPath + File.separator + "TestTables"), fileName);
            if (file == null) {
                throw new Exception("File '" + fileName + "' not found in directory '"
                        + new File(productPath + File.separator + "TestTables").getAbsolutePath() + "'.");
            }
            TableJson tableJson = IOHelper.parseTableJson(file);
            Key[] keys = tableJson.getKeys();
            String[][] values = tableJson.getValues();
            for (int j = 0; j < values[0].length; j++) {
                result.put(keys[j].getName(), values[0][j].replace("\\", File.separator));
            }
        }
    } catch (Exception e) {
        GribleSettings.getErrorsHandler().onAdaptorFail(e);
    }
    return result;
}

From source file:org.grible.adaptor.TestTable.java

private List<HashMap<String, String>> getValuesFromGrible(String entityType) {
    List<HashMap<String, String>> result = new ArrayList<HashMap<String, String>>();
    try {/*  w w w.  ja  va  2  s. co m*/
        if (GribleSettings.getAppType() == AppTypes.POSTGRESQL) {
            Connection conn = getConnection();
            Statement stmt = conn.createStatement();

            String nameColumn = "";
            if (entityType.equals("table")) {
                nameColumn = "name";
            } else {
                nameColumn = "classname";
            }

            String strKeys = null;
            String strValues = null;

            ResultSet rs = stmt.executeQuery("SELECT t.keys, t.values " + "FROM tables t "
                    + "INNER JOIN tabletypes tt ON t.type = tt.id "
                    + "INNER JOIN categories c ON t.categoryid=c.id "
                    + "INNER JOIN products p ON c.productid=p.id "
                    + "INNER JOIN tabletypes ctt ON c.type = ctt.id " + "WHERE tt.name='" + entityType
                    + "' AND t." + nameColumn + "='" + tableName + "' AND p.name='" + productName + "'");
            if (rs.next()) {
                strKeys = rs.getString("keys");
                strValues = rs.getString("values");
            }

            if (strKeys != null && strValues != null) {
                Gson gson = new Gson();
                Key[] keys = gson.fromJson(strKeys, Key[].class);
                String[][] values = gson.fromJson(strValues, String[][].class);
                for (int i = 0; i < values.length; i++) {
                    HashMap<String, String> row = new HashMap<String, String>();
                    for (int j = 0; j < values[0].length; j++) {
                        row.put(keys[j].getName(), values[i][j].replace("\\", File.separator));
                    }
                    result.add(row);
                }
            } else {
                throw new Exception(StringUtils.capitalize(entityType) + " with name '" + tableName
                        + "' not found in product '" + productName + "'.");
            }

            conn.close();
            rs.close();
            stmt.close();
        } else {

            File file = null;
            if (entityType.equals("table")) {
                String fileName = tableName + ".json";
                String sectionDir = "TestTables";
                file = IOHelper.searchFile(new File(productPath + File.separator + sectionDir), fileName);
                if (file == null) {
                    throw new Exception("File '" + fileName + "' not found in directory '"
                            + new File(productPath + File.separator + sectionDir).getAbsolutePath() + "'.");
                }
            } else {
                String className = tableName;
                String sectionDir = "DataStorages";
                file = IOHelper.searchFileByClassName(new File(productPath + File.separator + sectionDir),
                        className);
                if (file == null) {
                    throw new Exception("File with class name '" + className + "' not found in directory '"
                            + new File(productPath + File.separator + sectionDir).getAbsolutePath() + "'.");
                }
            }

            TableJson tableJson = IOHelper.parseTableJson(file);
            Key[] keys = tableJson.getKeys();
            String[][] values = tableJson.getValues();
            for (int i = 0; i < values.length; i++) {
                HashMap<String, String> row = new HashMap<String, String>();
                for (int j = 0; j < values[0].length; j++) {
                    row.put(keys[j].getName(), values[i][j].replace("\\", File.separator));
                }
                result.add(row);
            }
        }
    } catch (Exception e) {
        GribleSettings.getErrorsHandler().onAdaptorFail(e);
    }
    if (result.isEmpty()) {
        String message = "Grible error: " + entityType + " '" + tableName + "' is missing.";
        GribleSettings.getErrorsHandler().onAdaptorFail(new Exception(message));
    }
    return result;
}

From source file:org.grible.servlets.app.imp.AnvancedImport.java

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
 *      response)//from   w w w  .  ja  v  a  2  s .  c  om
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    try {
        if (Security.anyServletEntryCheckFailed(request, response)) {
            return;
        }
        Table currTable = (Table) request.getSession(false).getAttribute("importedTable");
        ExcelFile excelFile = (ExcelFile) request.getSession(false).getAttribute("importedFile");

        String option = request.getParameter("option"); // "addtoend",
        // "addfromrow"

        if (!ServletHelper.isJson()) {
            pDao = new PostgresDao();
        }

        if ("addtoend".equals(option)) {
            String[][] excelValues = excelFile.getValues();
            if (ServletHelper.isJson()) {
                String[][] oldValues = currTable.getTableJson().getValues();
                String[][] newValues = new String[oldValues.length + excelValues.length][oldValues[0].length];
                for (int i = 0; i < newValues.length; i++) {
                    if (i < oldValues.length) {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = oldValues[i][j];
                        }
                    } else {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = excelValues[i - oldValues.length][j];
                        }
                    }
                }
                currTable.getTableJson().setValues(newValues);
                currTable.save();
            } else {
                String[][] oldValues = currTable.getValues();
                String[][] newValues = new String[oldValues.length + excelValues.length][oldValues[0].length];
                for (int i = 0; i < newValues.length; i++) {
                    if (i < oldValues.length) {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = oldValues[i][j];
                        }
                    } else {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = excelValues[i - oldValues.length][j];
                        }
                    }
                }
                currTable.setValues(newValues);
                pDao.updateTable(currTable);
            }
        } else if ("addfromrow".equals(option)) {
            int startRow = 0;
            if (request.getParameter("startrow") != null) {
                if (StringUtils.isNumeric(request.getParameter("startrow"))) {
                    startRow = Integer.parseInt(request.getParameter("startrow"));
                } else {
                    throw new Exception(Lang.get("error") + ": " + Lang.get("startrownull"));
                }
            } else {
                throw new Exception(Lang.get("error") + ": " + Lang.get("startrownull"));
            }

            String[][] excelValues = excelFile.getValues();
            int excelValuesCount = excelValues.length;

            if (ServletHelper.isJson()) {
                String[][] oldValues = currTable.getTableJson().getValues();

                int rowsCount = oldValues.length;
                if (startRow > rowsCount) {
                    throw new Exception(Lang.get("error") + ": " + Lang.get("startrowoutofrange"));
                }
                int limit = rowsCount;
                if (rowsCount < (startRow - 1 + excelValuesCount)) {
                    limit = startRow - 1 + excelValuesCount;
                }
                String[][] newValues = new String[limit][oldValues[0].length];

                for (int i = 0; i < limit; i++) {
                    if ((i < startRow - 1) || (i >= startRow - 1 + excelValuesCount)) {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = oldValues[i][j];
                        }
                    } else {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = excelValues[i - (startRow - 1)][j];
                        }
                    }
                }
                currTable.getTableJson().setValues(newValues);
                currTable.save();
            } else {
                String[][] oldValues = currTable.getValues();

                int rowsCount = oldValues.length;
                if (startRow > rowsCount) {
                    throw new Exception(Lang.get("error") + ": " + Lang.get("startrowoutofrange"));
                }
                int limit = rowsCount;
                if (rowsCount < (startRow - 1 + excelValuesCount)) {
                    limit = startRow - 1 + excelValuesCount;
                }
                String[][] newValues = new String[limit][oldValues[0].length];

                for (int i = 0; i < limit; i++) {
                    if ((i < startRow - 1) || (i >= startRow - 1 + excelValuesCount)) {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = oldValues[i][j];
                        }
                    } else {
                        for (int j = 0; j < newValues[0].length; j++) {
                            newValues[i][j] = excelValues[i - (startRow - 1)][j];
                        }
                    }
                }
                currTable.setValues(newValues);
                pDao.updateTable(currTable);
            }
        }
        request.getSession(true).setAttribute("importedTable", null);
        request.getSession(false).setAttribute("importedFile", null);
        String message = StringUtils.capitalize(currTable.getType().toString().toLowerCase())
                + " imported successfully.";
        request.getSession(false).setAttribute("importResult", message);
        out.print("success");
    } catch (Exception e) {
        out.print(e.getLocalizedMessage());
        e.printStackTrace();
    }
    out.flush();
    out.close();
}

From source file:org.grouplens.lenskit.config.GroovyUtils.java

/**
 * Build an object using named arguments.
 * @param builder The builder to use./*  ww w  . j a v  a  2  s.c o  m*/
 * @param args The arguments.
 * @param <T> The type of object to be built.
 * @return A new object.
 */
public static <T> T buildObject(Builder<T> builder, Map<String, Object> args) {
    for (Map.Entry<String, Object> arg : args.entrySet()) {
        String name = arg.getKey();
        // Use Groovy to invoke, since we're called from Groovy
        InvokerHelper.invokeMethod(builder, "set" + StringUtils.capitalize(name), arg.getValue());
    }
    return builder.build();
}

From source file:org.grouplens.lenskit.data.text.Fields.java

/**
 * Get a field by name.  It first looks up the common fields, and if none of them apply, creates
 * a reflection-based field./*from ww  w. j  a  v  a2s.c  o  m*/
 *
 * @param eb The event builder.
 * @param name The field name.  The name can be suffixed with "?" to make it optional.
 * @return The field, or `null` if no such field can be defined.
 */
public static Field byName(Class<? extends EventBuilder> eb, String name) {
    Field field = commonField(name);
    if (field != null) {
        return field;
    }

    boolean optional = false;
    if (name.endsWith("?")) {
        optional = true;
        name = name.substring(0, name.length() - 1);
    }

    String setterName = "set" + StringUtils.capitalize(name);
    Method setter = null;
    Method annotated = null;
    for (Method m : eb.getMethods()) {
        FieldName nameAnnot = m.getAnnotation(FieldName.class);
        if (nameAnnot != null) {
            if (nameAnnot.value().equals(name)) {
                annotated = m;
            }
        } else if (m.getName().equals(setterName) && !m.isBridge()) {
            if (setter == null) {
                setter = m;
            } else {
                throw new IllegalArgumentException("Multiple methods named " + setterName);
            }
        }
    }
    if (annotated != null) {
        setter = annotated;
    }

    if (setter == null) {
        throw new IllegalArgumentException("No method found for field " + name);
    }
    Class<?>[] atypes = setter.getParameterTypes();
    if (atypes.length != 1) {
        throw new IllegalArgumentException("Method " + setter.getName() + " takes too many arguments");
    }
    final Method theSetter = setter;
    Class<?> atype = atypes[0];
    if (atype.isPrimitive()) {
        atype = ClassUtils.primitiveToWrapper(atype);
    }
    StringConverter<Object> convert = StringConvert.INSTANCE.findConverterNoGenerics(atype);
    if (convert == null) {
        throw new IllegalArgumentException("Field type " + atypes[0] + " not allowed.");
    }
    return new ReflectionField(name, theSetter, eb, atype, convert, optional);
}

From source file:org.grouplens.lenskit.eval.script.ConfigMethodInvoker.java

public Object invokeConfigurationMethod(final Object target, final String name, Object... args) {
    Preconditions.checkNotNull(target, "target object");

    if (args.length == 1 && args[0] instanceof Future) {
        Future<?> f = (Future<?>) args[0];
        if (f.isDone()) {
            try {
                Object arg = f.get();
                return invokeConfigurationMethod(target, name, arg);
            } catch (InterruptedException e) {
                throw new RuntimeException("interrupted waiting for dependency", e);
            } catch (ExecutionException e) {
                throw new RuntimeException(e.getCause());
            }//from w  w  w.  jav  a  2s.c  o m
        } else {
            Function<Object, Object> recur = new Function<Object, Object>() {
                @Nullable
                @Override
                public Object apply(@Nullable Object input) {
                    return invokeConfigurationMethod(target, name, input);
                }
            };
            ListenableFuture<?> f2 = Futures.transform(listenInPoolThread(f), recur);
            registerDep(target, f2);
            return f2;
        }
    }

    final String setterName = "set" + StringUtils.capitalize(name);
    final String adderName = "add" + StringUtils.capitalize(name);
    Supplier<Object> inv;
    // directly invoke
    inv = findMethod(target, name, args);
    if (inv == null) {
        inv = findBuildableMethod(target, name, args);
    }
    // invoke a setter
    if (inv == null) {
        inv = findMethod(target, setterName, args);
    }
    // invoke a buildable setter
    if (inv == null) {
        inv = findBuildableMethod(target, setterName, args);
    }
    // invoke an adder
    if (inv == null) {
        inv = findMethod(target, adderName, args);
    }
    // add from a list
    if (inv == null) {
        inv = findMultiMethod(target, adderName, args);
    }
    // invoke a buildable adder
    if (inv == null) {
        inv = findBuildableMethod(target, adderName, args);
    }

    if (inv != null) {
        return inv.get();
    } else {
        // try to invoke the method directly
        return DefaultGroovyMethods.invokeMethod(target, name, args);
    }

}

From source file:org.guess.generate.Generate.java

public static void main(String[] args) {

    // ==========  ?? ====================

    // ??????//from w  w w.j  ava 2  s. c o  m
    // ?{packageName}/{moduleName}/{dao,entity,service,web}/{subModuleName}/{className}

    // packageName
    // ????applicationContext.xmlsrping-mvc.xml?base-package?packagesToScan?4?
    String packageName = "net.iharding.modulesmeta";

    String moduleName = "meta"; // ???sys
    String className = "project"; // ??user
    String classAuthor = "Joe.zhang"; // 
    String functionName = "??"; // ??

    List<Field> fields = new ArrayList<Field>();
    fields.add(new Field("projectCode", "?", "String"));
    fields.add(new Field("projectName", "??", "String"));
    fields.add(new Field("remark", "", "String"));
    fields.add(new Field("createDate", "", "Date"));
    fields.add(new Field("updateDate", "", "Date"));
    fields.add(new Field("createId", "", "createId"));
    fields.add(new Field("updateId", "", "updateId"));

    // ???
    Boolean isEnable = true;

    // ==========  ?? ====================

    if (!isEnable) {
        logger.error("????isEnable = true");
        return;
    }

    if (StringUtils.isBlank(moduleName) || StringUtils.isBlank(moduleName) || StringUtils.isBlank(className)
            || StringUtils.isBlank(functionName)) {
        logger.error("??????????????");
        return;
    }

    // ?
    String separator = File.separator;

    // ?
    File projectPath = null;
    try {
        projectPath = new DefaultResourceLoader().getResource("").getFile();
        //         File projectPath = new File("D:/template");
        while (!new File(projectPath.getPath() + separator + "src" + separator + "main").exists()) {
            projectPath = projectPath.getParentFile();
        }
        logger.info("Project Path: {}", projectPath);

        // ?
        String tplPath = StringUtils.replace(
                projectPath.getAbsolutePath() + "/src/test/java/org/guess/generate/temp", "/", separator);
        logger.info("Template Path: {}", tplPath);

        // Java
        String javaPath = StringUtils.replaceEach(
                projectPath.getAbsolutePath() + "/src/main/java/" + StringUtils.lowerCase(packageName),
                new String[] { "/", "." }, new String[] { separator, separator });
        //         String javaPath = "D:/template";
        logger.info("Java Path: {}", javaPath);

        String viewPath = StringUtils.replace(
                projectPath + "/src/main/webapp/WEB-INF/content/" + moduleName + "/" + className, "/",
                separator);
        //         String viewPath = "D:/template";

        // ???
        Configuration cfg = new Configuration();
        FileUtils.isFolderExitAndCreate(tplPath);
        cfg.setDirectoryForTemplateLoading(new File(tplPath));

        // ???
        Map<String, Object> model = Maps.newHashMap();
        model.put("packageName", StringUtils.lowerCase(packageName));
        model.put("moduleName", StringUtils.lowerCase(moduleName));
        model.put("className", StringUtils.uncapitalize(className));
        model.put("ClassName", StringUtils.capitalize(className));
        model.put("classAuthor", StringUtils.isNotBlank(classAuthor) ? classAuthor : "Generate Tools");
        model.put("classVersion", DateUtil.getCurrenDate());
        model.put("functionName", functionName);
        model.put("tableName", model.get("moduleName") + "_" + model.get("className"));

        model.put("fields", fields);

        // ? Entity
        Template template = cfg.getTemplate("entity.ftl");
        String content = FreeMarkers.renderTemplate(template, model);
        String filePath = javaPath + separator + model.get("moduleName") + separator + "model" + separator
                + model.get("ClassName") + ".java";
        //         writeFile(content, filePath);
        logger.info("Entity: {}", filePath);

        // ? Dao
        template = cfg.getTemplate("dao.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator
                + model.get("ClassName") + "Dao.java";
        writeFile(content, filePath);
        logger.info("Dao: {}", filePath);

        // ? DaoImpl
        template = cfg.getTemplate("daoImpl.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "dao" + separator + "impl"
                + separator + model.get("ClassName") + "DaoImpl.java";
        writeFile(content, filePath);
        logger.info("Dao: {}", filePath);

        // ? Service
        template = cfg.getTemplate("service.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator
                + model.get("ClassName") + "Service.java";
        writeFile(content, filePath);
        logger.info("Service: {}", filePath);

        // ? Service
        template = cfg.getTemplate("serviceImpl.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "service" + separator + "impl"
                + separator + model.get("ClassName") + "ServiceImpl.java";
        writeFile(content, filePath);
        logger.info("Service: {}", filePath);

        // ? Controller
        template = cfg.getTemplate("controller.ftl");
        content = FreeMarkers.renderTemplate(template, model);
        filePath = javaPath + separator + model.get("moduleName") + separator + "controller" + separator
                + model.get("ClassName") + "Controller.java";
        writeFile(content, filePath);
        logger.info("Controller: {}", filePath);

        /*   // ? list.jsp
           template = cfg.getTemplate("list.ftl");
           content = FreeMarkers.renderTemplate(template, model);
           filePath = viewPath + separator + "list.jsp";
           writeFile(content, filePath);
           logger.info("Controller: {}", filePath);
                   
           // ? edit.jsp
           template = cfg.getTemplate("edit.ftl");
           content = FreeMarkers.renderTemplate(template, model);
           filePath = viewPath + separator + "edit.jsp";
           writeFile(content, filePath);
           logger.info("Controller: {}", filePath);*/

        logger.info("Generate Success.");
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.gvnix.addon.datatables.addon.DatatablesMetadata.java

public DatatablesMetadata(String identifier, JavaType aspectName,
        PhysicalTypeMetadata governorPhysicalTypeMetadata, DatatablesAnnotationValues annotationValues,
        JavaType entity, MemberDetails entityMemberDetails, List<FieldMetadata> identifierProperties,
        String entityPlural, Map<JavaSymbolName, DateTimeFormatDetails> datePatterns,
        JavaType webScaffoldAspectName, WebJpaBatchMetadata webJpaBatchMetadata,
        JpaQueryMetadata jpaQueryMetadata, WebScaffoldAnnotationValues webScaffoldAnnotationValues,
        Map<FinderMetadataDetails, QueryHolderTokens> findersRegistered, WebMetadataService webMetadataService,
        ProjectOperations projectOperations) {
    super(identifier, aspectName, governorPhysicalTypeMetadata);
    Validate.isTrue(isValid(identifier),
            "Metadata identification string '" + identifier + "' does not appear to be a valid");

    this.annotationValues = annotationValues;

    this.helper = new WebItdBuilderHelper(this, governorPhysicalTypeMetadata,
            builder.getImportRegistrationResolver());

    // Roo only uses one property
    this.entityIdentifier = identifierProperties.get(0);
    this.entityIdentifierType = entityIdentifier.getFieldType();
    this.entity = entity;
    this.entityMemberDetails = entityMemberDetails;
    this.entityName = entity.getSimpleTypeName();
    this.entityPlural = entityPlural;
    this.entityDatePatterns = datePatterns;
    this.webJpaBatchMetadata = webJpaBatchMetadata;
    this.jpaQueryMetadata = jpaQueryMetadata;
    this.webScaffoldAnnotationValues = webScaffoldAnnotationValues;

    // Prepare method names which includes entity plural
    this.findAllMethodName = new JavaSymbolName("findAll".concat(StringUtils.capitalize(entityPlural)));

    this.renderItemsMethodName = new JavaSymbolName("render".concat(StringUtils.capitalize(entityPlural)));

    this.findByParametersMethodName = new JavaSymbolName(
            "find".concat(StringUtils.capitalize(entityPlural)).concat("ByParameters"));

    this.entityListType = new JavaType(LIST.getFullyQualifiedTypeName(), 0, DataType.TYPE, null,
            Arrays.asList(entity));

    this.entityList = StringUtils.uncapitalize(entityPlural);

    // this.entityIdListType = new
    // JavaType(LIST.getFullyQualifiedTypeName(),
    // 0, DataType.TYPE, null, Arrays.asList(entityIdentifierType));

    this.entityIdArrayType = new JavaType(entityIdentifierType.getFullyQualifiedTypeName(), 1, DataType.TYPE,
            null, null);/*  www . j  a va 2  s . c  o m*/

    // store finders information
    if (findersRegistered != null) {
        this.findersRegistered = Collections.unmodifiableMap(findersRegistered);
    } else {
        this.findersRegistered = null;
    }

    this.webMetadataService = webMetadataService;

    this.projectOperations = projectOperations;

    // Adding precedence declaration
    // This aspect before webScaffold
    builder.setDeclarePrecedence(aspectName, webScaffoldAspectName);

    // Adding field definition
    builder.addField(getConversionServiceField());
    builder.addField(getMessageSourceField());
    builder.addField(getBeanWrapperField());
    builder.addField(getEntityManagerProvider());
    builder.addField(getDatatablesUtilsBean());
    builder.addField(getQuerydslUtilsBean());

    // Adding methods
    builder.addMethod(getListDatatablesRequestMethod());
    builder.addMethod(getPopulateDatatablesConfig());
    builder.addMethod(getListRooRequestMethod());
    builder.addMethod(getPopulateParameterMapMethod());
    builder.addMethod(getGetPropertyMapMethod());
    builder.addMethod(getGetPropertyMapUrlMethod());
    builder.addMethod(getSetDatatablesBaseFilterMethod(annotationValues));
    builder.addMethod(getColumnTypeRequestMethod());
    builder.addMethod(geti18nTextRequestMethod());

    // Detail methods
    builder.addMethod(getListDatatablesDetailMethod());
    builder.addMethod(getCreateDatatablesDetailMethod());
    builder.addMethod(getUpdateDatatablesDetailMethod());
    builder.addMethod(getDeleteDatatablesDetailMethod());

    // Add AJAX mode required methods
    if (isAjax()) {
        if (isStantardMode()) {
            builder.addMethod(getFindAllMethod());
            // Adding filters methods
            builder.addMethod(getCheckFilterExpressionsMethod());
        } else {
            if (isInlineEditing()) {
                // InlineEditing not supported on non-standard mode
                throw new IllegalArgumentException(
                        aspectName.getFullyQualifiedTypeName().concat(".@GvNIXDatatables: 'mode = ")
                                .concat(annotationValues.getMode()).concat("' can't use inlineEditing"));
            }
            // Render mode requires this methods
            builder.addMethod(getPopulateItemForRenderMethod());
            builder.addMethod(getRenderItemsMethod());
            builder.addMethod(getFindAllMethodRenderMode());

        }
        // add ajax request for finders
        if (this.findersRegistered != null) {
            for (Entry<FinderMetadataDetails, QueryHolderTokens> finder : this.findersRegistered.entrySet()) {
                if (finder.getValue() != null) {
                    builder.addMethod(getAjaxFinderMethod(finder.getKey(), finder.getValue()));
                }
            }
        }

        // Export via AJAX methods
        addAjaxExportMethods();
    } else if (!isStantardMode()) {
        // Non-Standard view mode requires AJAX data mode
        throw new IllegalArgumentException(
                aspectName.getFullyQualifiedTypeName().concat(".@GvNIXDatatables: 'mode = ")
                        .concat(annotationValues.getMode()).concat("' requires 'ajax = true'"));
    } else {
        // DOM standard mode requires finder by parameters
        builder.addMethod(getFindByParametersMethod());
    }
    if (isInlineEditing()) {
        if (!hasJpaBatchSupport()) {
            // InlineEditing requires batch support
            throw new IllegalArgumentException(aspectName.getFullyQualifiedTypeName().concat(
                    ". Inline editing requires batch support. Run 'jpa batch add' command or 'web mvc batch add' command"));
        }
        builder.addMethod(getJsonFormsMethod(true));
        builder.addMethod(getJsonFormsMethod(false));
        builder.addMethod(getRenderUpdateFormsMethod());
        builder.addMethod(getPopulateItemForRenderMethod());
    }

    // Create a representation of the desired output ITD
    itdTypeDetails = builder.build();
}