JavaTypeInfo javaTypeInfo = new JavaTypeInfo("java.lang.Integer");
java公用信息
- 注释: addJavaDocLine("This class corresponds to the database table
tb_alarm
"); - 注解: addAnnotation("@Bean");
- 作用域: setJavaScope(JavaKeywords.PUBLIC);
- final: setFinal(boolean isFinal);
- static: setStatic(boolean isStatic);
- 实例: Field field = new Field("age", new JavaTypeInfo("java.lang.Integer"));
- 初始值: setInitializationString(String initializationString);
- transient: setTransient(boolean transient);
- volatile: setVolatile(boolean volatile);
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 initializationBlock = new InitializationBlock();
- 内容: addBodyLine("new Integer(21)");
- 注释: addJavaDocLine("/**");
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 innerClass = new InnerClass(new JavaTypeInfo("com.Test"));
- 实例: Method method = new Method("getAge");
- isNative: setNative(boolean isNative);
- isSynchronized: setTransient(boolean isSynchronized);
- 内容: addBodyLine("Integer i = 1;");
- 是否构造器: setConstructor(boolean constructor);
- 参数: addParameter(Parameter parameter);
- 返回类型: setReturnType(JavaTypeInfo returnType);
- 抛出异常: addException(JavaTypeInfo exception);
- 实例: Parameter parameter = new Parameter(new JavaTypeInfo(Integer.class.getName()), "age");
- isVarargs: setVarargs(boolean isVarargs);
- 注解: addAnnotation(String annotation);