Auto Value Step Builder

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
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

Auto Value Step Builder
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

How to add to project

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

Dependencies

compile (8)

Group / Artifact Type Version
org.apache.velocity : velocity jar 1.7
org.apache.velocity : velocity-tools jar 2.0
com.google.auto.value : auto-value jar 1.5
com.google.auto : auto-common jar 0.8
com.google.auto.service : auto-service jar 1.0-rc3
com.google.code.findbugs : jsr305 jar 1.3.9
cz.jcode.auto.value : auto-value-step-builder-annotations jar 0.0.3
org.apiguardian : apiguardian-api jar 1.0.0

test (5)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.0.1
org.junit.jupiter : junit-jupiter-params jar 5.0.1
com.google.testing.compile : compile-testing jar 0.11
commons-io : commons-io jar 2.5
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