io.jonasg.bob.ConstructorPolicy Maven / Gradle / Ivy
package io.jonasg.bob;
/**
* Enumerates the policies for constructor behavior in the {@link Buildable}
* annotation context.
* This enumeration defines how the object construction must handle its
* constructor fields during
* instantiation through the builder pattern.
*
* These policies allow developers to specify whether all fields must be
* explicitly set
* before constructing an object or if missing fields can be initialized with
* default values.
*
*/
public enum ConstructorPolicy {
/**
* Requires all fields to be explicitly set in the constructor.
* If any field is not set, the builder will throw an exception.
* This policy ensures that the constructed object is fully initialized
* with all the specified fields, promoting immutability and thread-safety,
* assuming that all fields are properly handled.
*/
ENFORCED,
/**
* Allows the object to be constructed even if not all constructor parameters
* have
* been explicitly set. Fields not explicitly set will be initialized to their
* default values
* (e.g., {@code null} for object references, {@code 0} for {@code int},
* {@code false} for {@code boolean}, etc.).
*
* This policy is suitable for situations where not all fields are required
* to have a value, allowing for more flexible object creation.
*
*/
PERMISSIVE
}