Interface Instantiator<T>

All Known Implementing Classes:
ClassConstructorInstantiator, ProvidedFactoryInstantiator, RecordConstructorInstantiator, ReflectionInstantiator

public interface Instantiator<T>
Creates an instance of a class or record.
  • Method Summary

    Modifier and Type
    Method
    Description
    default T
    copy(Object original)
    Creates a new instance with all fields set to the same value as their counterparts from original.
    Creates an instance of the given type, with its field set to the given values.
  • Method Details

    • instantiate

      T instantiate(Map<Field,Object> values)
      Creates an instance of the given type, with its field set to the given values. If no value is given for a specific field, the field will be set to its default value: null for object references, 0 for numbers, false for booleans.
      Parameters:
      values - Values to assign to the instance's fields.
      Returns:
      An instance with assigned values.
    • copy

      default T copy(Object original)
      Creates a new instance with all fields set to the same value as their counterparts from original.
      Parameters:
      original - The instance to copy.
      Returns:
      A copy of the given original.