All Projects → ZacSweers → copydynamic

ZacSweers / copydynamic

Licence: Apache-2.0 license
Prototype of generating `copyDynamic` extension functions for kotlin data classes

Programming Languages

kotlin
9241 projects
shell
77523 projects

Projects that are alternatives of or similar to copydynamic

avaje-inject
Dependency injection via APT (source code generation) ala "Server side Dagger DI"
Stars: ✭ 114 (+100%)
Mutual labels:  annotation-processing, kapt
Kotlin-Annotation-Processor
Annotation Processor Sample in Kotlin
Stars: ✭ 19 (-66.67%)
Mutual labels:  annotation-processing, kapt
jeta
brooth.github.io/jeta
Stars: ✭ 21 (-63.16%)
Mutual labels:  code-generation, annotation-processing
simple-annotation-processor
Simple annotation processor example. Inspired by the idea of "How ButterKnife works?"
Stars: ✭ 54 (-5.26%)
Mutual labels:  code-generation, annotation-processing
linnea
Linnea is an experimental tool for the automatic generation of optimized code for linear algebra problems.
Stars: ✭ 60 (+5.26%)
Mutual labels:  code-generation
gg
General Golang Code Generator
Stars: ✭ 88 (+54.39%)
Mutual labels:  code-generation
codespawn
Code generator written in Rust
Stars: ✭ 34 (-40.35%)
Mutual labels:  code-generation
symbok-bundle
Symfony annotations bundle
Stars: ✭ 50 (-12.28%)
Mutual labels:  annotation-processing
domino-jackson
Jackson with Annotation processing
Stars: ✭ 46 (-19.3%)
Mutual labels:  annotation-processing
sisyphus-js
Sisyphus customized protobuf and gRPC runtime and code generator for JavaScript/TypeScript
Stars: ✭ 19 (-66.67%)
Mutual labels:  code-generation
Templates
CodeSmith Generator Templates
Stars: ✭ 52 (-8.77%)
Mutual labels:  code-generation
scalagen
WIP - Scalameta powered code generation
Stars: ✭ 38 (-33.33%)
Mutual labels:  code-generation
flatorize
Generate fast implementations of mathematical expressions. Inclues a linear algebra library.
Stars: ✭ 18 (-68.42%)
Mutual labels:  code-generation
go-zero
A cloud-native Go microservices framework with cli tool for productivity.
Stars: ✭ 23,294 (+40766.67%)
Mutual labels:  code-generation
Cojen
Java bytecode generation and disassembly tools
Stars: ✭ 28 (-50.88%)
Mutual labels:  code-generation
pony-capnp
Cap’n Proto plugin for generating serializable Pony classes. 🐴 - 🎩'n 🅿️
Stars: ✭ 19 (-66.67%)
Mutual labels:  code-generation
lintpack
Build Go linters from lintpack-compatible packages. Also serves as a framework for writing checkers.
Stars: ✭ 28 (-50.88%)
Mutual labels:  code-generation
brian2cuda
A brian2 extension to simulate spiking neural networks on GPUs
Stars: ✭ 46 (-19.3%)
Mutual labels:  code-generation
FunStripe
An F# library to connect to the Stripe API, including code generators to update the model and requests.
Stars: ✭ 35 (-38.6%)
Mutual labels:  code-generation
libjit
Unofficial libjit mirror.
Stars: ✭ 46 (-19.3%)
Mutual labels:  code-generation

CopyDynamic

Archived and unmaintained. Consider using https://github.com/kopykat-kt/kopykat instead


Build Status

Prototype of generating copyDynamic extension functions for data classes, such that you can do this:

@CopyDynamic
data class Foo(val bar: String = "bar", val baz: String = "baz", val fizz: String = "fizz")

And have a copyDynamic extension function generated to allow for dynamic setting of variables in a copy call.

val foo = Foo()

val newFoo = foo.copyDynamic {
  bar = "newBar"
  if (someCondition) baz = "newBaz"
}

Configuration

You can optionally specify a copydynamic.generated annotation processing option with a value of either "javax.annotation.processing.Generated" (JDK 9+) or "javax.annotation.Generated" (JDK <9).

Incremental annotation processing is disabled by default (as Kapt doesn't formally support this when generating Kotlin sources currently). This does appear to work in Android projects though with Kotlin 1.3.30+. If you want to try this, you can enable it via copdynamic.useFiler.

kapt {
  arguments {
    arg("copydynamic.generated", "javax.annotation.Generated")
    arg("copydynamic.useFiler", "true")
  }
}

Caveats

  • The generated intermediate builder has internal visibility for its constructor, which can be considered a bit of a leaky API. If you use this, it's recommended to put your models in a separate module to avoid leaking this.
  • Properties must be internal or public visibility.

Download

Maven Central

kapt 'io.sweers.copydynamic:copydynamic:x.y.z'
compileOnly 'io.sweers.copydynamic:copydynamic-annotations:x.y.z'

KDocs can be found here: https://zacsweers.github.io/copydynamic

License

Copyright (C) 2018 Zac Sweers

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].