@@ -0,0 +1,3355 @@
+/*%0A * Copyright 2018, TeamDev. All rights reserved.%0A *%0A * Redistribution and use in source and/or binary forms, with or without%0A * modification, must retain the above copyright notice and the following%0A * disclaimer.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0A%0Apackage io.spine.validate;%0A%0Aimport org.checkerframework.checker.nullness.qual.Nullable;%0A%0A/**%0A * A change in a %7B@linkplain io.spine.validate.FieldValue value of a field%7D.%0A */%0Apublic final class FieldValueChange %7B%0A%0A    /**%0A     * A value that used to be the value of the field.%0A     *%0A     * %3Cp%3ENullable because when a field is set for the first time, old value has never existed%0A     * and can be considered %7B@code null%7D.%0A     */%0A    private final @Nullable FieldValue oldValue;%0A%0A    /**%0A     * A value that the field is going to obtain as a result of this change.%0A     */%0A    private final FieldValue newValue;%0A%0A    /** Creates an instance of the field change from the given values. */%0A    private FieldValueChange(@Nullable FieldValue oldValue, FieldValue newValue) %7B%0A        this.oldValue = oldValue;%0A        this.newValue = newValue;%0A    %7D%0A%0A    /**%0A     * Creates a new instance of a field change based on the specified values.%0A     *%0A     * %3Cp%3E%7B@code oldValue%7D can be %7B@code null%7D, because a first time the field is set the old%0A     * value does not exist, therefore can be considered %7B@code null%7D.%0A     *%0A     * @param oldValue%0A     *         a value that the field had before this change%0A     * @param newValue%0A     *         a value that the field is going to have as a result of this change%0A     * @return a new instance of a field change%0A     */%0A    public static FieldValueChange of(@Nullable FieldValue oldValue, FieldValue newValue) %7B%0A        return new FieldValueChange(oldValue, newValue);%0A    %7D%0A%0A    /**%0A     * Creates a new instance of a field change that signifies the first change of the field.%0A     *%0A     * %3Cp%3EIf this method is used to instantiate a %7B@code FieldValueChange%7D, the old value is going%0A     * to be %7B@code null%7D.%0A     *%0A     * @param singleValue%0A     *         a value that the field is going to have as a result of this change%0A     * @return a new instance of a field change%0A     */%0A    static FieldValueChange firstValueEver(FieldValue singleValue) %7B%0A        return new FieldValueChange(null, singleValue);%0A    %7D%0A%0A    /** Returns a value that the field is going to have as a result of this change. */%0A    FieldValue newValue() %7B%0A        return newValue;%0A    %7D%0A%0A    /** Returns a value that the field used to have before this change took place.*/%0A    FieldValue oldValue() %7B%0A        return oldValue;%0A    %7D%0A%7D%0A

Introduce an entity that represents a change of the value of a field