package com.suse.salt.netapi.results;

import com.google.gson.annotations.SerializedName;

/**
 * Represents a change from some old value to a new one.
 * primarily used in salt for showing package changes
 *
 * @param <T> type of the changed value
 */
public class Change<T> {

    @SerializedName("old")
    private final T oldValue;
    @SerializedName("new")
    private final T newValue;

    /**
     * constructor
     * @param oldValue old value
     * @param newValue new value
     */
    public Change(T oldValue, T newValue) {
        this.oldValue = oldValue;
        this.newValue = newValue;
    }

    /**
     * the old value
     * @return old value
     */
    public T getOldValue() {
        return oldValue;
    }

    /**
     * the new value
     * @return new value
     */
    public T getNewValue() {
        return newValue;
    }
}

@@ -84,16 +84,53 @@
 dName;%0A%0A
+import java.util.function.Function;%0A%0A
 /**%0A * R
@@ -888,11 +888,459 @@
 e;%0A    %7D
+%0A%0A    /**%0A     * Applies a mapping function to both the old and the new value, wrapping the result%0A     * in a new Change.%0A     * @param fn the mapping function%0A     * @param %3CR%3E type returned by the mapping function%0A     * @return a new Change with mapped values%0A     */%0A    public %3CR%3E Change%3CR%3E map(Function%3CT, R%3E fn) %7B%0A        return new Change%3C%3E(%0A                fn.apply(getOldValue()),%0A                fn.apply(getNewValue())%0A        );%0A    %7D
 %0A%7D%0A

add map method