auto README

The project's README from github.com/google/auto. As one markdown file: README.md.

Auto

Build Status

A collection of source code generators for Java.

Overview

Java is full of code that is mechanical, repetitive, typically untested and sometimes the source of subtle bugs. Sounds like a job for robots!

The Auto subprojects are a collection of code generators that automate those types of tasks. They create the code you would have written, but without the bugs.

Save time. Save code. Save sanity.

Subprojects

License

Copyright 2013 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

auto (google/auto)

Searching Database…

10.6K ·GitHub
这是什么?Auto 是一组面向 Java 的源代码生成器,能自动生成开发者原本需要手动编写的、机械重复的样板代码。
这是一个库,还是一组独立的工具?它是一个综合性的集合,包含四个不同的注解处理器子项目:AutoFactory、AutoService、AutoValue 和 Common,每个子项目解决不同的代码生成问题。
我该如何开始使用其中一个生成器?将你需要的具体子项目(AutoFactory、AutoService 或 AutoValue)作为依赖添加到你的 Java 构建中,并为你的类添加注解;注解处理器随后会在编译时生成所需的支持代码。
这些工具需要特定的 Java 版本吗?AutoValue 需要 Java 8 或更高版本;其他子项目在编译期间通过标准的 Java 注解处理即可工作,不需要额外的运行时环境。
我需要为自己的使用场景选择合适的子项目吗?需要。没有一个能包揽所有功能的通用生成器:AutoFactory、AutoService、AutoValue 和 Common 各自针对不同的具体问题,因此你需要选择与你的开发需求相匹配的那一个。
AutoValue 究竟会生成什么?AutoValue 会根据你编写的一个简单抽象类,为 Java 8+ 中的不可变值类型类生成样板代码,例如构造函数、equals、hashCode 和 toString。
AutoFactory 有什么用?AutoFactory 会生成与 JSR-330 兼容的工厂类,无需手动编写用于依赖注入对象的工厂样板代码。
AutoService 解决了什么问题?AutoService 会生成 Java 的 ServiceLoader 机制所需的服务提供者配置文件,你无需手动维护这些文件。
为什么 Google 要开发这些工具,而不是手动编写代码?重复的 Java 样板代码机械枯燥,往往缺乏测试,还是微妙错误的常见来源,因此 Auto 的生成器能自动且正确地生成这些代码。
Creator
google
Size
53 MB
Stars
10.6K
Age
13y
Commits · 90 Days