Skip to content
Generic interfaces to the classical builder pattern and the less classical "freeze/thaw" pattern
Branch: master
Clone or download
fge Announce 1.2
* Work around bug with APK and duplicate files.
* Upgrade to gradle 1.11, wrapper.
* Remove pom.xml.

Francis Galiegue (11):
      Announce 1.1
      build.gradle: make gradle version explicit in wrapper task
      Use Spring's propdeps-plugins
      Modify license file placements to circumvent APK bug
      Update gradle version, wrapper
      Modify javadoc link to work around JDK 8's javadoc bug
      build.gradle: small cleanup
      Disable Spring's propdeps plugin for now
      Reenable test output...
      Update copyrights
      Remove pom.xml; can be generated from gradle if need be
Latest commit 4338342 Apr 13, 2014

Read me first

This project, as of version 1.1, is licensed under both LGPLv3 and ASL 2.0. See file LICENSE for more details. Versions 1.0 and lower are licensed under LGPLv3 only.


What this is

This package contains interfaces to help for two design patterns:

  • the builder pattern;
  • another pattern, which I came up with, called the "freeze/thaw pattern".

All in all, it consists of only three Java source files, one per interface. Full source code is included in this README.

Current version

The current version is 1.2.

Maven artifact




The full source of this interface is as follows:

public interface Builder<T>
    T build();

There is really no need to comment on this interface; it is pretty obvious.


These are two interfaces:

// Frozen
public interface Frozen<T extends Thawed<? extends Frozen<T>>>
    T thaw();

// Thawed
public interface Thawed<F extends Frozen<? extends Thawed<F>>>
    F freeze();

These interfaces are meant to be used in a pair of classes, where class F is immutable, and class T is a modifiable version of F. The recommended use is as follows:

  • F and T are in the same package; all instance variables of either class are package local;
  • F has no publicly available constructor;
  • F has a static factory method in order to return a "virgin" instance of T.

As you can see from the annotations (which are JSR 305 annotations), another part of the contract is that any F instance is immutable; as to T instances, there is no guarantee as to their thread safety.

In summary, the free/thaw pattern is a "reversible" builder pattern -- that is, a pattern where you can create, from a "frozen", immutable instance, an equivalent builder instance bearing the same characteristics.

You can’t perform that action at this time.