热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javajpa自动生成,SpringBootJPA代码自动生成其三

之前说过怎么生成,可以参考这里可以一键生成entity、service、repository类了。这个是对生成的内容进行扩展,在写一些基础、公共的组件时

之前说过怎么生成,可以参考这里可以一键生成entity、service、repository类了。

这个是对生成的内容进行扩展,在写一些基础、公共的组件时,不太希望使用lombok注解,反而需要最原始的get、set方法,这个就是加上可以生成get、set方法的配置。顺便加上了注释。

先看看新的实体类

不使用lombok

package com.example.genpojodemo.entity;

import javax.persistence.*;

/**

* 用户表

*/

@Entity

@Table(name = "user")

public class User {

/**

* id

* default value: null

*/

@Id

@Column(name = "id", nullable = false, length = 20)

private Long id;

/**

* 用户名

* default value: 'a'

*/

@Column(name = "username", nullable = true, length = 255)

private String username;

/**

* 密码

* default value: 'b'

*/

@Column(name = "password", nullable = true, length = 255)

private String password;

/**

* 盐

* default value: 'b'

*/

@Column(name = "salt", nullable = true, length = 255)

private String salt;

/**

* 生成时间

* default value: CURRENT_TIMESTAMP(6)

*/

@Column(name = "create_time", nullable = true, length = 6)

private java.util.Date createTime;

public Long getId() {

return this.id;

}

public void setId(Long id) {

this.id = id;

}

public String getUsername() {

return this.username;

}

public void setUsername(String username) {

this.username = username;

}

public String getPassword() {

return this.password;

}

public void setPassword(String password) {

this.password = password;

}

public String getSalt() {

return this.salt;

}

public void setSalt(String salt) {

this.salt = salt;

}

public java.util.Date getCreateTime() {

return this.createTime;

}

public void setCreateTime(java.util.Date createTime) {

this.createTime = createTime;

}

}

使用lombok

package com.example.genpojodemo.entity;

import lombok.Data;

import javax.persistence.*;

/**

* 用户表

*/

@Data

@Entity

@Table(name = "user")

public class User {

/**

* id

* default value: null

*/

@Id

@Column(name = "id", nullable = false, length = 20)

private Long id;

/**

* 用户名

* default value: 'a'

*/

@Column(name = "username", nullable = true, length = 255)

private String username;

/**

* 密码

* default value: 'b'

*/

@Column(name = "password", nullable = true, length = 255)

private String password;

/**

* 盐

* default value: 'b'

*/

@Column(name = "salt", nullable = true, length = 255)

private String salt;

/**

* 生成时间

* default value: CURRENT_TIMESTAMP(6)

*/

@Column(name = "create_time", nullable = true, length = 6)

private java.util.Date createTime;

}

来看看Groovy内容

import com.intellij.database.model.DasTable

import com.intellij.database.model.ObjectKind

import com.intellij.database.util.Case

import com.intellij.database.util.DasUtil

config = [

impSerializable : false,

extendBaseEntity : false,

extendBaseService: false,

useLombok : true, // 不使用会生成get、set方法

// 不生成哪个就注释哪个

generateItem : [

"Entity",

// "Service",

// "Repository",

// "RepositoryCustom",

// "RepositoryImpl",

]

]

baseEntityPackage = "com.yija.project.framework.base.BaseEntity"

baseServicePackage = "com.yija.project.framework.base.BaseService"

baseEntityProperties = ["id", "createDate", "lastModifiedDate", "version"]

typeMapping = [

(~/(?i)bool|boolean|tinyint/) : "Boolean",

(~/(?i)bigint/) : "Long",

(~/int/) : "Integer",

(~/(?i)float|double|decimal|real/): "Double",

(~/(?i)datetime|timestamp/) : "java.util.Date",

(~/(?i)date/) : "java.sql.Date",

(~/(?i)time/) : "java.sql.Time",

(~/(?i)/) : "String"

]

FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->

SELECTION.filter {

it instanceof DasTable && it.getKind() == ObjectKind.TABLE

}.each {

generate(it, dir)

}

}

// 生成对应的文件

def generate(table, dir) {

def entityPath = "${dir.toString()}\\entity",

servicePath = "${dir.toString()}\\service",

repPath = "${dir.toString()}\\repository",

repImpPath = "${dir.toString()}\\repository\\impl",

controllerPath = "${dir.toString()}\\controller"

mkdirs([entityPath, servicePath, repPath, repImpPath, controllerPath])

System.out.println(table.getName())

def entityName = javaName(table.getName(), true)

def fields = calcFields(table)

def basePackage = clacBasePackage(dir)

if (isGenerate("Entity")) {

genUTF8File(entityPath, "${entityName}.java").withPrintWriter { out -> genEntity(out, table, entityName, fields, basePackage) }

}

if (isGenerate("Service")) {

genUTF8File(servicePath, "${entityName}Service.java").withPrintWriter { out -> genService(out, table, entityName, fields, basePackage) }

}

if (isGenerate("Repository")) {

genUTF8File(repPath, "${entityName}Repository.java").withPrintWriter { out -> genRepository(out, table, entityName, fields, basePackage) }

}

if (isGenerate("RepositoryCustom")) {

genUTF8File(repPath, "${entityName}RepositoryCustom.java").withPrintWriter { out -> genRepositoryCustom(out, entityName, basePackage) }

}

if (isGenerate("RepositoryImpl")) {

genUTF8File(repImpPath, "${entityName}RepositoryImpl.java").withPrintWriter { out -> genRepositoryImpl(out, table, entityName, fields, basePackage) }

}

}

// 是否需要被生成

def isGenerate(itemName) {

config.generateItem.contains(itemName)

}

// 指定文件编码方式,防止中文注释乱码

def genUTF8File(dir, fileName) {

new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, fileName)), "utf-8"))

}

// 生成每个字段

def genProperty(out, field) {

out.println ""

out.println "\t/**"

out.println "\t * ${field.comment}"

out.println "\t * default value: ${field.default}"

out.println "\t */"

// 默认表的第一个字段为主键

if (field.position == 1) {

out.println "\t@Id"

}

out.println "\t@Column(name = \"${field.colum}\", nullable = ${!field.isNotNull}, length = ${field.len})"

out.println "\tprivate ${field.type} ${field.name};"

}

// 生成get、get方法

def genGetSet(out, field) {

// get

out.println "\t"

out.println "\tpublic ${field.type} get${field.name.substring(0, 1).toUpperCase()}${field.name.substring(1)}() {"

out.println "\t\treturn this.${field.name};"

out.println "\t}"

// set

out.println "\t"

out.println "\tpublic void set${field.name.substring(0, 1).toUpperCase()}${field.name.substring(1)}(${field.type} ${field.name}) {"

out.println "\t\tthis.${field.name} = ${field.name};"

out.println "\t}"

}

// 生成实体类

def genEntity(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.entity;"

out.println ""

if (config.extendBaseEntity) {

out.println "import $baseEntityPackage;"

}

if (config.useLombok) {

out.println "import lombok.Data;"

out.println ""

}

if (config.impSerializable) {

out.println "import java.io.Serializable;"

out.println ""

}

out.println "import javax.persistence.*;"

out.println ""

out.println "/**"

out.println " * ${table.getComment()}"

out.println " */"

if (config.useLombok) {

out.println "@Data"

}

out.println "@Entity"

out.println "@Table(name = \"${table.getName()}\")"

out.println "public class $entityName${config.extendBaseEntity ? " extends BaseEntity" : ""}${config.impSerializable ? " implements Serializable" : ""} {"

if (config.extendBaseEntity) {

fields = fields.findAll { it ->

!baseEntityProperties.any { it1 -> it1 == it.name }

}

}

fields.each() {

genProperty(out, it)

}

if (!config.useLombok) {

fields.each() {

genGetSet(out, it)

}

}

out.println "}"

}

// 生成Service

def genService(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.service;"

out.println ""

out.println "import ${basePackage}.repository.${entityName}Repository;"

if (config.extendBaseService) {

out.println "import $baseServicePackage;"

out.println "import ${basePackage}.entity.$entityName;"

}

out.println "import org.springframework.stereotype.Service;"

out.println ""

out.println "import javax.annotation.Resource;"

out.println ""

out.println "@Service"

out.println "public class ${entityName}Service${config.extendBaseService ? " extends BaseService" : ""} {"

out.println ""

out.println "\t@Resource"

out.println "\tprivate ${entityName}Repository rep;"

out.println "}"

}

// 生成Repository

def genRepository(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.repository;"

out.println ""

out.println "import ${basePackage}.entity.$entityName;"

out.println "import org.springframework.data.jpa.repository.JpaRepository;"

out.println ""

out.println "public interface ${entityName}Repository extends JpaRepository, ${entityName}RepositoryCustom {"

out.println ""

out.println "}"

}

// 生成RepositoryCustom

def genRepositoryCustom(out, entityName, basePackage) {

out.println "package ${basePackage}.repository;"

out.println ""

out.println "public interface ${entityName}RepositoryCustom {"

out.println ""

out.println "}"

}

// 生成RepositoryImpl

def genRepositoryImpl(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.repository.impl;"

out.println ""

out.println "import ${basePackage}.repository.${entityName}RepositoryCustom;"

out.println "import org.springframework.stereotype.Repository;"

out.println ""

out.println "import javax.persistence.EntityManager;"

out.println "import javax.persistence.PersistenceContext;"

out.println ""

out.println "@Repository"

out.println "public class ${entityName}RepositoryImpl implements ${entityName}RepositoryCustom {"

out.println ""

out.println "\t@PersistenceContext"

out.println "\tprivate EntityManager em;"

out.println "}"

}

// 生成文件夹

def mkdirs(dirs) {

dirs.forEach {

def f = new File(it)

if (!f.exists()) {

f.mkdirs()

}

}

}

def clacBasePackage(dir) {

dir.toString()

.replaceAll("^.+\\\\src\\\\main\\\\java\\\\", "")

.replaceAll("\\\\", ".")

}

def isBaseEntityProperty(property) {

baseEntityProperties.find { it == property } != null

}

// 转换类型

def calcFields(table) {

DasUtil.getColumns(table).reduce([]) { fields, col ->

def spec = Case.LOWER.apply(col.getDataType().getSpecification())

def typeStr = typeMapping.find { p, t -> p.matcher(spec).find() }.value

fields += [[

name : javaName(col.getName(), false),

colum : col.getName(),

type : typeStr,

len : col.getDataType().toString().replaceAll("[^\\d]", ""),

default : col.getDefault(),

comment : col.getComment(),

isNotNull: col.isNotNull(),

position : col.getPosition(),

// getDefault : col.getDefault(),

// getParent : col.getParent(),

// getTable : col.getTable(),

// getDataType : col.getDataType(),

// isNotNull : col.isNotNull(),

// getWeight : col.getWeight(),

// getDocumentation : col.getDocumentation(),

// getTableName : col.getTableName(),

// getName : col.getName(),

// getLanguage : col.getLanguage(),

// getTypeName : col.getTypeName(),

// isDirectory : col.isDirectory(),

// isValid : col.isValid(),

// getComment : col.getComment(),

// getText : col.getText(),

// getDeclaration : col.getDeclaration(),

// getPosition : col.getPosition(),

// canNavigate : col.canNavigate(),

// isWritable : col.isWritable(),

// getIcon : col.getIcon(),

// getManager : col.getManager(),

// getDelegate : col.getDelegate(),

// getChildren : col.getChildren(),

// getKind : col.getKind(),

// isCaseSensitive : col.isCaseSensitive(),

// getProject : col.getProject(),

// getDataSource : col.getDataSource(),

// getVirtualFile : col.getVirtualFile(),

// getMetaData : col.getMetaData(),

// canNavigateToSource : col.canNavigateToSource(),

// getDisplayOrder : col.getDisplayOrder(),

// getDasParent : col.getDasParent(),

// getLocationString : col.getLocationString(),

// getDependences : col.getDependences(),

// getBaseIcon : col.getBaseIcon(),

// getNode : col.getNode(),

// getTextLength : col.getTextLength(),

// getFirstChild : col.getFirstChild(),

// getLastChild : col.getLastChild(),

// getNextSibling : col.getNextSibling(),

// getTextOffset : col.getTextOffset(),

// getPrevSibling : col.getPrevSibling(),

// getPresentation : col.getPresentation(),

// isPhysical : col.isPhysical(),

// getTextRange : col.getTextRange(),

// getPresentableText : col.getPresentableText(),

// textToCharArray : col.textToCharArray(),

// getStartOffsetInParent: col.getStartOffsetInParent(),

// getContext : col.getContext(),

// getUseScope : col.getUseScope(),

// getResolveScope : col.getResolveScope(),

// getReferences : col.getReferences(),

// getReference : col.getReference(),

// getContainingFile : col.getContainingFile(),

// getOriginalElement : col.getOriginalElement(),

// getNavigationElement : col.getNavigationElement(),

// getUserDataString : col.getUserDataString(),

// isUserDataEmpty : col.isUserDataEmpty(),

// getDbParent : col.getDbParent(),

]]

}

}

def javaName(str, capitalize) {

def s &#61; str.split(/(?<&#61;[^\p{IsLetter}])/).collect { Case.LOWER.apply(it).capitalize() }

.join("").replaceAll(/[^\p{javaJavaIdentifierPart}]/, "_").replaceAll(/_/, "")

capitalize || s.length() &#61;&#61; 1 ? s : Case.LOWER.apply(s[0]) &#43; s[1..-1]

}

下面注释的一大堆东西&#xff0c;就是可以获取信息的方法&#xff0c;有兴趣可以自己试试。

今天(2019/3/25)发现枚举类型不需要长度&#xff0c;调整了下生成代码&#xff0c;

import com.intellij.database.model.DasTable

import com.intellij.database.model.ObjectKind

import com.intellij.database.util.Case

import com.intellij.database.util.DasUtil

config &#61; [

impSerializable : true,

extendBaseEntity : true,

extendBaseService: true,

useLombok : true, // 不使用会生成get、set方法

// 不生成哪个就注释哪个

generateItem : [

"Entity",

// "Service",

// "Repository",

// "RepositoryCustom",

// "RepositoryImpl",

]

]

baseEntityPackage &#61; "com.yija.project.framework.base.BaseEntity"

baseServicePackage &#61; "com.yija.project.framework.base.BaseService"

baseEntityProperties &#61; ["id", "createDate", "lastModifiedDate", "version"]

typeMapping &#61; [

(~/(?i)bool|boolean|tinyint/) : "Boolean",

(~/(?i)bigint/) : "Long",

(~/int/) : "Integer",

(~/(?i)float|double|decimal|real/): "Double",

(~/(?i)datetime|timestamp/) : "java.util.Date",

(~/(?i)date/) : "java.sql.Date",

(~/(?i)time/) : "java.sql.Time",

(~/(?i)/) : "String"

]

FILES.chooseDirectoryAndSave("Choose directory", "Choose where to store generated files") { dir ->

SELECTION.filter {

it instanceof DasTable && it.getKind() &#61;&#61; ObjectKind.TABLE

}.each {

generate(it, dir)

}

}

// 生成对应的文件

def generate(table, dir) {

def entityPath &#61; "${dir.toString()}\\entity",

servicePath &#61; "${dir.toString()}\\service",

repPath &#61; "${dir.toString()}\\repository",

repImpPath &#61; "${dir.toString()}\\repository\\impl",

controllerPath &#61; "${dir.toString()}\\controller"

mkdirs([entityPath, servicePath, repPath, repImpPath, controllerPath])

System.out.println(table.getName())

def entityName &#61; javaName(table.getName(), true)

def fields &#61; calcFields(table)

def basePackage &#61; clacBasePackage(dir)

if (isGenerate("Entity")) {

genUTF8File(entityPath, "${entityName}.java").withPrintWriter { out -> genEntity(out, table, entityName, fields, basePackage) }

}

if (isGenerate("Service")) {

genUTF8File(servicePath, "${entityName}Service.java").withPrintWriter { out -> genService(out, table, entityName, fields, basePackage) }

}

if (isGenerate("Repository")) {

genUTF8File(repPath, "${entityName}Repository.java").withPrintWriter { out -> genRepository(out, table, entityName, fields, basePackage) }

}

if (isGenerate("RepositoryCustom")) {

genUTF8File(repPath, "${entityName}RepositoryCustom.java").withPrintWriter { out -> genRepositoryCustom(out, entityName, basePackage) }

}

if (isGenerate("RepositoryImpl")) {

genUTF8File(repImpPath, "${entityName}RepositoryImpl.java").withPrintWriter { out -> genRepositoryImpl(out, table, entityName, fields, basePackage) }

}

}

// 是否需要被生成

def isGenerate(itemName) {

config.generateItem.contains(itemName)

}

// 指定文件编码方式&#xff0c;防止中文注释乱码

def genUTF8File(dir, fileName) {

new PrintWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, fileName)), "utf-8"))

}

// 生成每个字段

def genProperty(out, field) {

out.println ""

out.println "\t/**"

out.println "\t * ${field.comment}"

out.println "\t * default value: ${field.default}"

out.println "\t */"

// 默认表的第一个字段为主键

if (field.position &#61;&#61; 1) {

out.println "\t&#64;Id"

}

// 枚举不需要长度

out.println "\t&#64;Column(name &#61; \"${field.colum}\", nullable &#61; ${!field.isNotNull}${field.dataType &#61;&#61; "enum" ? "" : ", length &#61; $field.len"})"

out.println "\tprivate ${field.type} ${field.name};"

}

// 生成get、get方法

def genGetSet(out, field) {

// get

out.println "\t"

out.println "\tpublic ${field.type} get${field.name.substring(0, 1).toUpperCase()}${field.name.substring(1)}() {"

out.println "\t\treturn this.${field.name};"

out.println "\t}"

// set

out.println "\t"

out.println "\tpublic void set${field.name.substring(0, 1).toUpperCase()}${field.name.substring(1)}(${field.type} ${field.name}) {"

out.println "\t\tthis.${field.name} &#61; ${field.name};"

out.println "\t}"

}

// 生成实体类

def genEntity(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.entity;"

out.println ""

if (config.extendBaseEntity) {

out.println "import $baseEntityPackage;"

}

if (config.useLombok) {

out.println "import lombok.Data;"

out.println ""

}

if (config.impSerializable) {

out.println "import java.io.Serializable;"

out.println ""

}

out.println "import javax.persistence.*;"

out.println ""

out.println "/**"

out.println " * ${table.getComment()}"

out.println " */"

if (config.useLombok) {

out.println "&#64;Data"

}

out.println "&#64;Entity"

out.println "&#64;Table(name &#61; \"${table.getName()}\")"

out.println "public class $entityName${config.extendBaseEntity ? " extends BaseEntity" : ""}${config.impSerializable ? " implements Serializable" : ""} {"

if (config.extendBaseEntity) {

fields &#61; fields.findAll { it ->

!baseEntityProperties.any { it1 -> it1 &#61;&#61; it.name }

}

}

fields.each() {

genProperty(out, it)

}

if (!config.useLombok) {

fields.each() {

genGetSet(out, it)

}

}

out.println "}"

}

// 生成Service

def genService(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.service;"

out.println ""

out.println "import ${basePackage}.repository.${entityName}Repository;"

if (config.extendBaseService) {

out.println "import $baseServicePackage;"

out.println "import ${basePackage}.entity.$entityName;"

}

out.println "import org.springframework.stereotype.Service;"

out.println ""

out.println "import javax.annotation.Resource;"

out.println ""

out.println "&#64;Service"

out.println "public class ${entityName}Service${config.extendBaseService ? " extends BaseService" : ""} {"

out.println ""

out.println "\t&#64;Resource"

out.println "\tprivate ${entityName}Repository rep;"

out.println "}"

}

// 生成Repository

def genRepository(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.repository;"

out.println ""

out.println "import ${basePackage}.entity.$entityName;"

out.println "import org.springframework.data.jpa.repository.JpaRepository;"

out.println ""

out.println "public interface ${entityName}Repository extends JpaRepository, ${entityName}RepositoryCustom {"

out.println ""

out.println "}"

}

// 生成RepositoryCustom

def genRepositoryCustom(out, entityName, basePackage) {

out.println "package ${basePackage}.repository;"

out.println ""

out.println "public interface ${entityName}RepositoryCustom {"

out.println ""

out.println "}"

}

// 生成RepositoryImpl

def genRepositoryImpl(out, table, entityName, fields, basePackage) {

out.println "package ${basePackage}.repository.impl;"

out.println ""

out.println "import ${basePackage}.repository.${entityName}RepositoryCustom;"

out.println "import org.springframework.stereotype.Repository;"

out.println ""

out.println "import javax.persistence.EntityManager;"

out.println "import javax.persistence.PersistenceContext;"

out.println ""

out.println "&#64;Repository"

out.println "public class ${entityName}RepositoryImpl implements ${entityName}RepositoryCustom {"

out.println ""

out.println "\t&#64;PersistenceContext"

out.println "\tprivate EntityManager em;"

out.println "}"

}

// 生成文件夹

def mkdirs(dirs) {

dirs.forEach {

def f &#61; new File(it)

if (!f.exists()) {

f.mkdirs()

}

}

}

def clacBasePackage(dir) {

dir.toString()

.replaceAll("^.&#43;\\\\src\\\\main\\\\java\\\\", "")

.replaceAll("\\\\", ".")

}

def isBaseEntityProperty(property) {

baseEntityProperties.find { it &#61;&#61; property } !&#61; null

}

// 转换类型

def calcFields(table) {

DasUtil.getColumns(table).reduce([]) { fields, col ->

def spec &#61; Case.LOWER.apply(col.getDataType().getSpecification())

def typeStr &#61; typeMapping.find { p, t -> p.matcher(spec).find() }.value

fields &#43;&#61; [[

name : javaName(col.getName(), false),

colum : col.getName(),

type : typeStr,

dataType : col.getDataType().toString().replaceAll(/\(.*\)/, "").toLowerCase(),

len : col.getDataType().toString().replaceAll(/[^\d]/, ""),

default : col.getDefault(),

comment : col.getComment(),

isNotNull: col.isNotNull(),

position : col.getPosition(),

// getDefault : col.getDefault(),

// getParent : col.getParent(),

// getTable : col.getTable(),

// getDataType : col.getDataType(),

// isNotNull : col.isNotNull(),

// getWeight : col.getWeight(),

// getDocumentation : col.getDocumentation(),

// getTableName : col.getTableName(),

// getName : col.getName(),

// getLanguage : col.getLanguage(),

// getTypeName : col.getTypeName(),

// isDirectory : col.isDirectory(),

// isValid : col.isValid(),

// getComment : col.getComment(),

// getText : col.getText(),

// getDeclaration : col.getDeclaration(),

// getPosition : col.getPosition(),

// canNavigate : col.canNavigate(),

// isWritable : col.isWritable(),

// getIcon : col.getIcon(),

// getManager : col.getManager(),

// getDelegate : col.getDelegate(),

// getChildren : col.getChildren(),

// getKind : col.getKind(),

// isCaseSensitive : col.isCaseSensitive(),

// getProject : col.getProject(),

// getDataSource : col.getDataSource(),

// getVirtualFile : col.getVirtualFile(),

// getMetaData : col.getMetaData(),

// canNavigateToSource : col.canNavigateToSource(),

// getDisplayOrder : col.getDisplayOrder(),

// getDasParent : col.getDasParent(),

// getLocationString : col.getLocationString(),

// getDependences : col.getDependences(),

// getBaseIcon : col.getBaseIcon(),

// getNode : col.getNode(),

// getTextLength : col.getTextLength(),

// getFirstChild : col.getFirstChild(),

// getLastChild : col.getLastChild(),

// getNextSibling : col.getNextSibling(),

// getTextOffset : col.getTextOffset(),

// getPrevSibling : col.getPrevSibling(),

// getPresentation : col.getPresentation(),

// isPhysical : col.isPhysical(),

// getTextRange : col.getTextRange(),

// getPresentableText : col.getPresentableText(),

// textToCharArray : col.textToCharArray(),

// getStartOffsetInParent: col.getStartOffsetInParent(),

// getContext : col.getContext(),

// getUseScope : col.getUseScope(),

// getResolveScope : col.getResolveScope(),

// getReferences : col.getReferences(),

// getReference : col.getReference(),

// getContainingFile : col.getContainingFile(),

// getOriginalElement : col.getOriginalElement(),

// getNavigationElement : col.getNavigationElement(),

// getUserDataString : col.getUserDataString(),

// isUserDataEmpty : col.isUserDataEmpty(),

// getDbParent : col.getDbParent(),

]]

}

}

def javaName(str, capitalize) {

def s &#61; str.split(/(?<&#61;[^\p{IsLetter}])/).collect { Case.LOWER.apply(it).capitalize() }

.join("").replaceAll(/[^\p{javaJavaIdentifierPart}]/, "_").replaceAll(/_/, "")

capitalize || s.length() &#61;&#61; 1 ? s : Case.LOWER.apply(s[0]) &#43; s[1..-1]

}



推荐阅读
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • 本文介绍了如何使用C#制作Java+Mysql+Tomcat环境安装程序,实现一键式安装。通过将JDK、Mysql、Tomcat三者制作成一个安装包,解决了客户在安装软件时的复杂配置和繁琐问题,便于管理软件版本和系统集成。具体步骤包括配置JDK环境变量和安装Mysql服务,其中使用了MySQL Server 5.5社区版和my.ini文件。安装方法为通过命令行将目录转到mysql的bin目录下,执行mysqld --install MySQL5命令。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 本文介绍了一个Java猜拳小游戏的代码,通过使用Scanner类获取用户输入的拳的数字,并随机生成计算机的拳,然后判断胜负。该游戏可以选择剪刀、石头、布三种拳,通过比较两者的拳来决定胜负。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • flowable工作流 流程变量_信也科技工作流平台的技术实践
    1背景随着公司业务发展及内部业务流程诉求的增长,目前信息化系统不能够很好满足期望,主要体现如下:目前OA流程引擎无法满足企业特定业务流程需求,且移动端体 ... [详细]
  • Java在运行已编译完成的类时,是通过java虚拟机来装载和执行的,java虚拟机通过操作系统命令JAVA_HOMEbinjava–option来启 ... [详细]
  • 在Java中,我会做这样的事情:classPerson{privateRecordrecord;publicStringname(){record().get(name);}p ... [详细]
  • 本文介绍了如何在给定的有序字符序列中插入新字符,并保持序列的有序性。通过示例代码演示了插入过程,以及插入后的字符序列。 ... [详细]
author-avatar
寒宝儿_____
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有