同步操作将从 Gitee 极速下载/javapoet 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
ParameterSpec
.MethodSpec.overriding()
.JavaFile.writeToPath()
and JavaFile.writeToFile()
methods that return paths to the
generated file as Path
and File
respectively.TypeSpec.alwaysQualify()
API to avoid clashes involving nested type names.CodeBlock
s to MethodSpec
's control flow methods.Builder
types mutable.CodeBlock.clear()
.Charset
to JavaFile.writeTo()
.ClassName.simpleNames()
by memoizing results.CodeWriter.resolve()
as all nested simple names
of a TypeSpec
get pre-computed.TypeName.Builder.setName()
to allow overriding names passed in the constructor.TypeName.canonicalName()
.\\R
instead of \n
as line separator in CodeWriter.emitAndIndent()
.TypeSpec.toBuilder()
.ParameterSpec
from a VariableElement
.ClassName
.final
modifier on a ParameterSpec
.TypeName.get()
would throw on error types, masking
other errors in an annotation processing round. This is fixed with a test to prevent future
regressions!TYPE_USE
annotations on each enclosing ClassName
.TypeName.get(TypeElement)
. There was a problem getting an
element's kind when building from source ABIs.$Z
as an optional newline (zero-width space) if a line may exceed 100 chars.CodeBlock.join()
and CodeBlock.joining()
let you join codeblocks by delimiters.CodeBlock.Builder.isEmpty()
.addStatement(CodeBlock)
overloads for CodeBlock
and MethodSpec
.$
.ClassName.get()
.MethodSpec.Builder.addNamedCode()
and TypeSpec.anonymousClassBuilder(CodeBlock)
.New: Basic support for line wrapping. Use $W
to insert a Wrappable Whitespace character. It'll
emit either a single space or a newline with appropriate indentation.
New: Named arguments in CodeBlock
. These are intended to make larger code snippets easier to
read:
Map<String, Object> map = new LinkedHashMap<>();
map.put("count", 3);
map.put("greeting", "Hello, ");
map.put("system", System.class);
String template = ""
+ "for (int i = 0; i < $count:L; i++) {\n"
+ " $system:T.out.println($greeting:S + list.get(i));\n"
+ "}\n";
CodeBlock.Builder builder = CodeBlock.builder();
builder.addNamed(template, map);
New: addJavadoc(CodeBlock)
overloads for TypeSpec, MethodSpec, and FieldSpec.
New: MethodSpec.addComment()
makes it easy to add a // single-line comment.
New: ClassName.getReflectionName()
returns a string like java.util.Map$Entry
.
Fix: Always write UTF-8. Previously JavaPoet would use the system default charset which was potentially inconsistent across environments.
Fix: Permit (constant) fields to be defined in annotation types.
Outer<String>.Inner
.TypeName.isBoxedPrimitive()
.CodeBlock.of()
, a handy factory method for building code blocks.TypeSpec
factory methods that take a ClassName
.TypeName.annotated()
adds an annotation to a type.TypeVariableName.withBounds()
adds bounds to a type variable.TypeSpec.Builder.addInitializerBlock()
adds an instance initializer.TypeSpec.Kind
enum public. This can be used to check if a TypeSpec
is a class,
interface, enum, or annotation.private
on annotation members.MethodSpec.Builder
.ErrorType
like a regular DeclaredType
in TypeName.get()
. This should make it
easier to write annotation processors.TypeName
instances are only equal if their annotations are equal.import static
! See JavaFile.Builder.addStaticImport()
variants.NameAllocator.newName(String)
for creating a one-off name without a tag.TypeVariableName
is part of ParameterizedTypeName
.add("$1S", "a", "b")
.AnnotationSpec.get(Annotation)
.TypeName.annotated()
can attach annotations like @Nullable
directly to
types. This works for both top-level types and type parameters as in List<@Nullable String>
.equals()
and hashCode()
on AnnotationSpec
, CodeBlock
, FieldSpec
, JavaFile
,
MethodSpec
, ParameterSpec
, TypeName
, and TypeSpec
.NameAllocator.clone()
to refine a NameAllocator for use in an inner scope code block.TypeVariableName
gets a self-referential type.NameAllocator
API makes it easy to declare non-conflicting names.TypeName.get(TypeMirror)
.$1T
and $2N
. Indexes can be used to refer to
the same argument multiple times in a single format string.addStaticBlock()
.MethodSpec.overriding()
retains annotations.$T
and $N
.MethodSpec.varargs(boolean)
to generate varags methods.AnnotationSpec.get()
and MethodSpec.overriding()
to create annotations and methods from
the javax.lang.model
API.JavaFile.toJavaFileObject()
.DEFAULT
modifier.toBuilder()
methods to build upon objects already constructed.@interface
annotation types.TypeName.box()
and TypeName.unbox()
convenience APIs.nextControlFlow()
accepts arguments.WildcardTypeName.get(WildcardType)
no longer throws a NullPointerException
.javapoet
. We renamed the it so you
can simultaneously use the old JavaWriter API and our new builder-based APIs in one project..java
file from top to bottom,
you now define members in whatever way is convenient.StringLiteral
type which encapsulates the behavior of stringLiteral
.emitEnumValue
variant which exposes a boolean of whether the current value is the last.java.lang
in compressType
.setIndent
.beginConstructor
method is a semantically clearer alternative for constructors.emitEnumValues
method emits a list of values followed by semicolon.emitImports
now supports Class
arguments directly.int
-based modifier methods have been removed.setCompressingTypes
controls whether types are emitted as fully-qualified or not.stringLiteral
now correctly handles escapes and control characters.Set
of Modifier
s rather than an int
. The int
methods are
now deprecated for removal in JavaPoet 1.0.emitSingleLineComment
.com.squareup.javawriter
.throws
clause on methods.type
API for helping build generic types.compressType
API.Initial release.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。