Bull
BULL - Bean Utils Light Library
Install / Use
/learn @ExpediaGroup/BullREADME
Bean Utils Light Library
BULL is a Java Bean to Java Bean transformer that recursively copies data from one object to another, it is generic, flexible, reusable, configurable, and incredibly fast. It's the only library able to transform Mutable, Immutable, and Mixed bean without any custom configuration.
Start using
A tutorial that integrates the library can be found here.
All BULL modules are available on Maven Central:
-
Bean BOM
It contains all the modules available in the project
<dependency>
<groupId>com.expediagroup.beans</groupId>
<artifactId>bull-bom</artifactId>
<version>x.y.z</version>
<type>pom</type>
<scope>import</scope>
</dependency>
-
Bean Transformer
<dependency>
<groupId>com.expediagroup.beans</groupId>
<artifactId>bull-bean-transformer</artifactId>
<version>x.y.z</version>
</dependency>
-
MapTransformer
<dependency>
<groupId>com.expediagroup.beans</groupId>
<artifactId>bull-map-transformer</artifactId>
<version>x.y.z</version>
</dependency>
The project provides two different builds, one compatible with jdk 8 (or above),
one with jdk 11 and on with jdk 17 or above.
In case you need to integrate it in a:
-
jdk 8please refer to CHANGELOG-JDK8 -
jdk 11please refer to CHANGELOG-JDK11 -
jdk 15CHANGELOG -
Suggestions
Some jdk versions remove the Java Bean constructor's argument names from the compiled code and this may cause problems to the library.
On top of that, it's suggested to configure the maven-compiler-plugin, inside your project, as follow:
<build>
...
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<parameters>true</parameters>
<forceJavacCompilerUse>true</forceJavacCompilerUse>
</configuration>
</plugin>
</plugins>
</pluginManagement>
...
</build>
Maven build
Full build
./mvnw clean install
or on Windows
mvnw.cmd clean install
Skip test coverage and checkstyle check
./mvnw clean install -P relaxed
or on Windows
mvnw.cmd clean install -P relaxed
Check for dependencies update
mvn versions:display-dependency-updates -P check-for-updates
or on Windows
mvnw.cmd versions:display-dependency-updates -P check-for-updates
Features:
- support copy of immutable beans.
- support copy of mutable beans.
- support copy of hybrid beans (some fields private and some not).
- support copy of Java Records.
- support copy of Java beans without getter and setter methods.
- support copy with Java primitive type.
- support copy with Java Collection type. e.g.
List<BeanA> => List<BeanB> - support copy with nested map fields. e.g.
Map<String, Map<String, String>> - support copy with array containing primitive types. e.g.
String[]=>String[] - support copy with an array type. e.g.
BeanA[]=>BeanB[] - support copy with property name mapping. e.g.
int id => int userId - support copy with recursion copy.
- support validation through annotations.
- support copy of beans with different field's name.
- support lambda function field transformation.
- support copy of java bean built through Builder.
- easy usage, declarative way to define the property mapping (in case of different names), or simply adding the Lombok annotations.
- allows setting the default value for all objects not existing in the source object.
- allows skipping transformation for a given set of fields.
- supports the retrieval of the value from getters if a field does not exist in the source object.
- supports the automatic conversion of primitive types.
Feature samples
- Bean Transformation
- Bean Validation
- Primitive Type conversion
- Map Transformation
- Supported Builder Pattern
- How to use it in Kotlin
Bean transformation samples
Simple case:
public class FromBean { public class ToBean {
private final String name; @NotNull
private final BigInteger id; public BigInteger id;
private final List<FromSubBean> subBeanList; private final String name;
private List<String> list; private final List<String> list;
private final FromSubBean subObject; private final List<ToSubBean> subBeanList;
private ImmutableToSubFoo subObject;
// all constructors // all args constructor
// getters and setters... // getters and setters...
}
And one line code as:
ToBean toBean = beanUtils.getTransformer().transform(fromBean, ToBean.class);
Different field names copy:
From class and To class with different field names:
public class FromBean { public class ToBean {
private final String name; private final String differentName;
private final int id; private final int id;
private final List<FromSubBean> subBeanList; private final List<ToSubBean> subBeanList;
private final List<String> list; private final List<String> list;
private final FromSubBean subObject; private final ToSubBean subObject;
// getters...
public ToBean(final String differentName,
final int id,
} final List<ToSubBean> subBeanList,
final List<String> list,
final ToSubBean subObject) {
th
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
