Skip to content

fillmore-labs/value-comparison

Folders and files

NameName
Last commit message
Last commit date
Feb 28, 2022
Nov 20, 2021
Dec 6, 2021
Jan 15, 2024
Jan 15, 2024
Oct 26, 2021
Mar 29, 2023
Mar 4, 2025
Nov 18, 2021
Nov 26, 2021
Nov 18, 2021
Feb 26, 2025
Oct 26, 2021
Mar 29, 2023
Oct 26, 2021
Oct 26, 2021
Dec 7, 2022
Mar 4, 2025
Oct 26, 2021
Jan 15, 2024

Repository files navigation

Value Objects in Java

13a9640ff1e11890cfcfc26bde3dcc40ffd6617f062e67a35e badge maintainability

Demo code about value objects and how to create them in Java.

Purpose

This source demonstrates how to create value objects in Java using various annotation processors.

Evaluated Libraries

Also, simple record classes, Scala case class amd Kotlin data class examples are included for demonstration purposes.

Structure

In com.fillmore_labs.talk.value.simple.* we have simple classes, one EmailAddress which demonstrates the power of being able to check value objects for consistency during construction and Person, which show how different libraries handle optional parameters and documentation propagation.

com.fillmore_labs.talk.value.inheritance.* and com.fillmore_labs.talk.value.composition.* demonstrates the composition over inheritance principle and why value objects can not meaningfully extend each other.

Running

Prerequisites

You need Bazelisk installed, see also Installing Bazel using Bazelisk.

macOS

Using HomeBrew enter

brew install bazelisk

Windows

Using Chocolatey enter

choco install bazelisk

Enable developer mode:

  1. Open Windows settings

  2. Go to ā€œUpdate & securityā€, then ā€œFor developersā€

  3. Under ā€œDeveloper Modeā€ section enable ā€œInstall apps from any source, including loose filesā€.

or run with administrator privileges.

Main App

The main app simply demonstrates the toString() method with a simple structure. Run it with

bazelisk run //:value-comparison

Tests

To run all tests, use

bazelisk test //src/test/...

References