Auto Value Step Builder Annotations

AutoValue extension to create step builder pattern for AutoValue properties

License

License

Categories

Categories

Auto Application Layer Libs Code Generators
GroupId

GroupId

cz.jcode.auto.value
ArtifactId

ArtifactId

auto-value-step-builder-annotations
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

Auto Value Step Builder Annotations
AutoValue extension to create step builder pattern for AutoValue properties
Project URL

Project URL

https://github.com/sopak/auto-value-step-builder
Source Code Management

Source Code Management

https://github.com/sopak/auto-value-step-builder

Download auto-value-step-builder-annotations

How to add to project

<!-- https://jarcasting.com/artifacts/cz.jcode.auto.value/auto-value-step-builder-annotations/ -->
<dependency>
    <groupId>cz.jcode.auto.value</groupId>
    <artifactId>auto-value-step-builder-annotations</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/cz.jcode.auto.value/auto-value-step-builder-annotations/
implementation 'cz.jcode.auto.value:auto-value-step-builder-annotations:0.0.3'
// https://jarcasting.com/artifacts/cz.jcode.auto.value/auto-value-step-builder-annotations/
implementation ("cz.jcode.auto.value:auto-value-step-builder-annotations:0.0.3")
'cz.jcode.auto.value:auto-value-step-builder-annotations:jar:0.0.3'
<dependency org="cz.jcode.auto.value" name="auto-value-step-builder-annotations" rev="0.0.3">
  <artifact name="auto-value-step-builder-annotations" type="jar" />
</dependency>
@Grapes(
@Grab(group='cz.jcode.auto.value', module='auto-value-step-builder-annotations', version='0.0.3')
)
libraryDependencies += "cz.jcode.auto.value" % "auto-value-step-builder-annotations" % "0.0.3"
[cz.jcode.auto.value/auto-value-step-builder-annotations "0.0.3"]

Dependencies

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.0.1
org.junit.jupiter : junit-jupiter-engine jar 5.0.1

Project Modules

There are no modules declared in this project.

auto-value-step-builder

AutoValue extension to create step builder pattern for AutoValue properties

Build Status Codacy Badge

This extension was inspired by http://www.svlada.com/step-builder-pattern/

Java - gradle

plugins {
    id "java"
    id "net.ltgt.apt" version "0.12"
    id "idea"
}

repositories {
    mavenCentral()
}

dependencies {
    compileOnly "cz.jcode.auto.value:auto-value-step-builder-annotations:0.0.3"
    compileOnly "cz.jcode.auto.value:auto-value-step-builder:0.0.3"
}

idea.module {

    inheritOutputDirs = false

    sourceDirs += file('build/generated/source/apt/main')

    outputDir file('build/classes/main')
    testOutputDir file('build/classes/test')

}

Usage

package test;

import com.google.auto.value.AutoValue;
import cz.jcode.auto.value.step.builder.AutoValueStepBuilder;

import javax.annotation.Nullable;

@AutoValue
@AutoValueStepBuilder
public abstract class Value {
    public abstract String required1();

    public abstract String required2();

    public abstract String required3();

    @Nullable
    public abstract String optional1();

    @Nullable
    public abstract String optional2();

    public static AutoValue_Value.Required1Step step() {
        return AutoValue_Value.step();
    }

    public static AutoValue_Value.Required1LazyStep lazyStep() {
        return AutoValue_Value.lazyStep();
    }
}

Simple Example

package test;

public class Main {
    public static void main(String[] args) {
        Value.step()
                .required1("string")
                .required2("string")
                .required3("string")
                .optional()
                .optional1("optional")
                .optional2(null)
                .build();

        Value.lazyStep()
                .required1(() -> "string")
                .required2(() -> "string")
                .required3(() -> "string")
                .optional()
                .optional1(() -> "optional")
                .optional2(() -> null)
                .build();
    }
}

Versions

Version
0.0.3
0.0.2
0.0.1