Description
ShapeShift is a Kotlin first object mapping library. We have built ShapeShift because we wanted a simple to use, minimal boiler plate mapping engine, that is also flexible and supports the most advanced use cases.
ShapeShift️ alternatives and similar libraries
Based on the "Web" category.
Alternatively, view shapeshift alternatives based on common mentions on social networks and blogs.
-
ktor
Framework for quickly creating connected applications in Kotlin with minimal effort -
javalin
A simple and modern Java and Kotlin web framework [Moved to: https://github.com/javalin/javalin] -
apollo-android
:robot: A strongly-typed, caching GraphQL client for the JVM, Android, and Kotlin multiplatform. -
http4k
The Functional toolkit for Kotlin HTTP applications. http4k provides a simple and uniform way to serve, consume, and test HTTP services. -
spark-kotlin
A Spark DSL in idiomatic kotlin // dependency: com.sparkjava:spark-kotlin:1.0.0-alpha -
skrape.it
A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion. -
hexagon
Hexagon is a microservices toolkit written in Kotlin. Its purpose is to ease the building of services (Web applications or APIs) that run inside a cloud platform. -
firefly
Firefly is an asynchronous web framework for rapid development of high-performance web application. -
fritz2
Easily build reactive web-apps in Kotlin based on flows and coroutines. -
A pure Kotlin, UI framework
A pure Kotlin UI framework for the Web (and desktop). -
Kanary
A minimalist web framework for building REST APIs in Kotlin/Java. -
alpas
🚀 The Rapid and Delightful Kotlin Web Framework. Easy, elegant, and productive! -
vaadin-on-kotlin
Writing full-stack statically-typed web apps on JVM at its simplest -
yested
A Kotlin framework for building web applications in Javascript. -
lambda-kotlin-request-router
A REST request routing layer for AWS lambda handlers written in Kotlin -
tekniq
A framework designed around Kotlin providing Restful HTTP Client, JDBC DSL, Loading Cache, Configurations, Validations, and more -
sponge
sponge is a website crawler and links downloader command-line tool -
Pellet
An opinionated, Kotlin-first web framework that helps you write fast, concise, and correct backend services 🚀. -
bootique-kotlin
Provides extension functions and features for smooth development with Bootique and Kotlin. -
Zeko-RestApi
Asynchronous web framework for Kotlin. Create REST APIs in Kotlin easily with automatic Swagger/OpenAPI doc generation -
komock
KoMock - Simple HTTP/Consul/SpringConfig http server framework written in Kotlin. Wiremock use cases -
voyager-server-spring-boot-starter
Easily create REST endpoints with permissions (access control level) and hooks includeded
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of ShapeShift️ or a related project?
Popular Comparisons
README
ShapeShift️
A Kotlin/Java library for intelligent object mapping and conversion between objects.
Overview
ShapeShift is a Kotlin first object mapping library. We have built ShapeShift because we wanted a simple to use, minimal boiler plate mapping engine, that is also flexible and supports the most advanced use cases.
Built with Kotlin in mind, ShapeShift was designed around its ecosystem and best practices. The library has 2 main tools for mapping:
- Annotations - Fully featured annotation based mapping, just add annotations to your objects and ShapeShift handles the rest. Including using custom field transformers, conditional mapping, advanced object decoration and much more. (Kotlin Example, Java Example)
- Kotlin DSL - A Kotlin DSL allowing you to define the relations between objects. This allows you to map objects you can't change (or don't want to), like objects from 3rd party libraries. Additionally you can define inline transformations, conditions and decorations, enabling deep customization and very advanced mapping. (Kotlin Example)
- Java Builder - The equivalent Java API for the Kotlin DSL. Allowing you to define the relations between objects without modifying their code, and map objects you can't change (or don't want to). (Java Example)
ShapeShift main features:
- Auto Mapping
- Custom field transformers
- Default transformers
- Deep mapping
- Multiple mapping targets
- Conditional mapping
- Mapping decorators
- Seamless spring integration
- Native Android support
Documentation
To learn how to get started with ShapeShift, visit the official documentation website. You'll find in-depth documentation, tips and guides to help you get up and running.
Installation
Requirements
- Minimum supported Kotlin version: 1.6.X
- Minimum supported Java version: 1.8
Maven
<dependency>
<groupId>dev.krud</groupId>
<artifactId>shapeshift</artifactId>
<version>0.6.0</version>
</dependency>
Gradle
Groovy DSL
implementation 'dev.krud:shapeshift:0.6.0'
Kotlin DSL
implementation("dev.krud:shapeshift:0.6.0")
Quickstart
Kotlin
Kotlin DSL
// Source Class
data class Source(
val firstName: String,
val lastName: String,
val birthDate: LocalDate
)
// Target Class
data class Target(
var firstName: String = "",
var lastName: String = "",
var birthYear: Int = 0
)
fun main() {
/**
* Initialize ShapeShift with a mapping definition from From to To
*/
val shapeShift = ShapeShiftBuilder()
.withMapping<Source, Target> {
// Map firstName
Source::firstName mappedTo Target::firstName
// Map lastName
Source::lastName mappedTo Target::lastName
// Map birthDate to birthYear with a transformation function
Source::birthDate mappedTo Target::birthYear withTransformer { (originalValue) ->
originalValue?.year
}
}
.build()
// Initialize Source
val source = Source("John", "Doe", LocalDate.of(1980, 1, 1))
// Perform the mapping
val result = shapeShift.map<Source, Target>(source)
// Returns: To(firstName=John, lastName=Doe, birthYear=1980)
}
Kotlin Annotation
// Source Class
@DefaultMappingTarget(Target::class)
data class Source(
@MappedField
val firstName: String,
@MappedField
val lastName: String,
@MappedField(mapTo = "birthYear", transformer = LocalDateToYearTransformer::class)
val birthDate: LocalDate
)
// Target Class
data class Target(
var firstName: String = "",
var lastName: String = "",
var birthYear: Int = 0
)
// Define the transformer which will transform the local date to a year
class LocalDateToYearTransformer : MappingTransformer<LocalDate, Int> {
override fun transform(context: MappingTransformerContext<out LocalDate>): Int? {
return context.originalValue?.year
}
}
fun main() {
/**
* Initialize ShapeShift and register the transformer
*/
val shapeShift = ShapeShiftBuilder()
.withTransformer(LocalDateToYearTransformer())
.build()
// Initialize Source
val source = Source("John", "Doe", LocalDate.of(1980, 1, 1))
// Perform the mapping
val result = shapeShift.map<Source, Target>(source)
// Returns: To(firstName=John, lastName=Doe, birthYear=1980)
}
Java
Java Builder
// Source.java
class Source {
private String firstName;
private String lastName;
private LocalDate birthDate;
// Constructor
// Getters
// Setters
// ToString
}
// Target.java
class Target {
private String firstName;
private String lastName;
private int birthYear;
// Constructor
// Getters
// Setters
// ToString
}
// Example.java
class Example {
public static void main(String[] args) {
/**
* Initialize ShapeShift with a mapping definition from From to To
*/
ShapeShift shapeShift = new ShapeShiftBuilder()
.withMapping(
new MappingDefinitionBuilder(Source.class, Target.class)
// Map firstName
.mapField("firstName", "firstName")
// Map lastName
.mapField("lastName", "lastName")
// Map birthDate to birthYear with a transformation function
.mapField("birthDate", "birthYear").withTransformer(ctx -> ((LocalDate) ctx.getOriginalValue()).getYear())
.build()
)
.build();
// Initialize Source
Source source = new Source("John", "Doe", LocalDate.of(1980, 1, 1));
// Perform the mapping
Target result = shapeShift.map(source, Target.class);
// Returns: To(firstName=John, lastName=Doe, birthYear=1980)
}
}
Java Annotation
// Source.java
@DefaultMappingTarget(Target.class)
class Source {
@MappedField
private String firstName;
@MappedField
private String lastName;
@MappedField(mapTo = "birthYear", transformer = LocalDateToYearTransformer.class)
private LocalDate birthDate;
// Constructor
// Getters
// Setters
// ToString
}
// Target.java
class Target {
private String firstName;
private String lastName;
private int birthYear;
// Constructor
// Getters
// Setters
// ToString
}
// Define the transformer which will transform the local date to a year
// LocalDateToYearTransformer.java
class LocalDateToYearTransformer implements MappingTransformer<LocalDate, Integer> {
@Override
public Integer transform(MappingTransformerContext<? extends LocalDate> context) {
return context.getOriginalValue().getYear();
}
}
// Example.java
class Example {
public static void main(String[] args) {
/**
* Initialize ShapeShift
*/
ShapeShift shapeShift = new ShapeShiftBuilder()
.withTransformer(LocalDate.class, Integer.class, new LocalDateToYearTransformer())
.build();
// Initialize Source
Source source = new Source("John", "Doe", LocalDate.of(1980, 1, 1));
// Perform the mapping
Target result = shapeShift.map(source, Target.class);
// Returns: To(firstName=John, lastName=Doe, birthYear=1980)
}
}
Examples
The [example](example/) directory contains several independent scenarios for common use cases of this library.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. See [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
License
ShapeShift is licensed under the MIT license. For more information, please see the [LICENSE](LICENSE) file.
*Note that all licence references and agreements mentioned in the ShapeShift️ README section above
are relevant to that project's source code only.