javacode


License

License

GroupId

GroupId

com.github.fartherp
ArtifactId

ArtifactId

javacode
Last Version

Last Version

2.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

javacode
javacode
Project URL

Project URL

https://github.com/fartherp/javacode
Source Code Management

Source Code Management

https://github.com/fartherp/javacode

Download javacode

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.fartherp/javacode/ -->
<dependency>
    <groupId>com.github.fartherp</groupId>
    <artifactId>javacode</artifactId>
    <version>2.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.fartherp/javacode/
implementation 'com.github.fartherp:javacode:2.0.4'
// https://jarcasting.com/artifacts/com.github.fartherp/javacode/
implementation ("com.github.fartherp:javacode:2.0.4")
'com.github.fartherp:javacode:jar:2.0.4'
<dependency org="com.github.fartherp" name="javacode" rev="2.0.4">
  <artifact name="javacode" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.fartherp', module='javacode', version='2.0.4')
)
libraryDependencies += "com.github.fartherp" % "javacode" % "2.0.4"
[com.github.fartherp/javacode "2.0.4"]

Dependencies

test (1)

Group / Artifact Type Version
org.testng : testng jar 6.14.3

Project Modules

There are no modules declared in this project.

生成java文件

Build Status Coverage Status Maven Central Sonatype Nexus (Snapshots) GitHub release License Project Stats
Quality gate

java类型类

JavaTypeInfo javaTypeInfo = new JavaTypeInfo("java.lang.Integer");

JavaElement

java公用信息

  1. 注释: addJavaDocLine("This class corresponds to the database table tb_alarm");
  2. 注解: addAnnotation("@Bean");
  3. 作用域: setJavaScope(JavaKeywords.PUBLIC);
  4. final: setFinal(boolean isFinal);
  5. static: setStatic(boolean isStatic);

Field(字段)

  1. 实例: Field field = new Field("age", new JavaTypeInfo("java.lang.Integer"));
  2. 初始值: setInitializationString(String initializationString);
  3. transient: setTransient(boolean transient);
  4. volatile: setVolatile(boolean volatile);

Sample Code

JavaTypeInfo javaTypeInfo = new JavaTypeInfo("java.lang.Integer");
Field field = new Field("age", javaTypeInfo);
String fieldStr = field.getFormattedContent(1);

结果: Integer age;

JavaTypeInfo javaTypeInfo = new JavaTypeInfo("java.lang.Integer");
Field field = new Field("age", javaTypeInfo);
field.setInitializationString("new Integer(21)");
String fieldStr = field.getFormattedContent(1);

结果: Integer age = new Integer(21);

InitializationBlock(初始模块)

  1. 实例: InitializationBlock initializationBlock = new InitializationBlock();
  2. 内容: addBodyLine("new Integer(21)");
  3. 注释: addJavaDocLine("/**");

Sample Code

InitializationBlock initializationBlock = new InitializationBlock(true);
String str = initializationBlock.getFormattedContent(0);
assertEquals(str, "static {\r\n}");
InitializationBlock initializationBlock = new InitializationBlock();
initializationBlock.addBodyLine("int age = 27;");
initializationBlock.addJavaDocLine("/**");
initializationBlock.addJavaDocLine(" * this age");
initializationBlock.addJavaDocLine(" */");
String str = initializationBlock.getFormattedContent(0);
assertEquals(str, "/**\r\n * this age\r\n */\r\n{\r\n    int age = 27;\r\n}");

InnerClass(类/内部类)

  1. 实例: InnerClass innerClass = new InnerClass(new JavaTypeInfo("com.Test"));

Method(方法)

  1. 实例: Method method = new Method("getAge");
  2. isNative: setNative(boolean isNative);
  3. isSynchronized: setTransient(boolean isSynchronized);
  4. 内容: addBodyLine("Integer i = 1;");
  5. 是否构造器: setConstructor(boolean constructor);
  6. 参数: addParameter(Parameter parameter);
  7. 返回类型: setReturnType(JavaTypeInfo returnType);
  8. 抛出异常: addException(JavaTypeInfo exception);

Parameter(参数)

  1. 实例: Parameter parameter = new Parameter(new JavaTypeInfo(Integer.class.getName()), "age");
  2. isVarargs: setVarargs(boolean isVarargs);
  3. 注解: addAnnotation(String annotation);

Versions

Version
2.0.4
2.0.3
2.0.2
2.0.1
1.0.2
1.0.1
1.0.0