KReplica
Home
Playground
Guide
Home
Playground
Guide
Starter Template:
1. Basic Replication
2. Versioned DTOs
3. Nominal Typing Part I: Usage Guide
4. Nominal Typing Part II: Edge Case Examples
5. Directly Applying Annotations
6. Serialization Part I: The Apply Annotation
7. Serialization Part II: Advanced Features
8. Contextual Nesting (Unversioned)
9. Contextual Nesting (Versioned)
10. The Hide Annotation
Editor
Output
Run
Reset All
Reset All
Clear Output
package io.availe.demo.playground import io.availe.Replicate import io.availe.models.DtoVariant import java.util.UUID // The @Replicate.Model annotation requests DATA, CREATE, and PATCH variants for this interface. @Replicate.Model(variants = [DtoVariant.DATA, DtoVariant.CREATE, DtoVariant.PATCH]) private interface UserProfile { // We specify that `id` will ONLY be created in the DATA variant. // By only allowing `id` in the DATA variant, we effectively make it read only. // A common use case for this is to make `id` managed by the database. @Replicate.Property(include = [DtoVariant.DATA]) val id: UUID // These properties have no override, so they will be created // in all the variants defined in @Replicate.Model (DATA, PATCH, CREATE) val username: String val email: String // This property is excluded from the CREATE variant. // We thus avoid contaminating our CREATE variant with unneeded fields. @Replicate.Property(exclude = [DtoVariant.CREATE]) val banReason: String }
Click "Run" to see the generated code.
Run
Reset All
Reset All
Clear Output