@@ -0,0 +1,2335 @@
+/*%0A * Copyright 2019-present Facebook, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.litho;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A/**%0A * Class represents a DynamicValue, and provides users with ability to change the value, by exposing%0A * one public method %7B@link #set(Object)%7D It also allows attaching listeners (package level access),%0A * and takes care of notifying them when the held value changes.%0A *%0A * @param %3CT%3E type of value held%0A */%0Apublic class DynamicValue%3CT%3E %7B%0A%0A  private T mValue;%0A  private final Set%3COnValueChangeListener%3CT%3E%3E mListeners = new HashSet%3C%3E();%0A%0A  public DynamicValue(T mValue) %7B%0A    this.mValue = mValue;%0A  %7D%0A%0A  /**%0A   * Sets current value and notifies all the attached listeners%0A   *%0A   * @param value the new value%0A   */%0A  public void set(T value) %7B%0A    if (mValue == value %7C%7C (mValue != null && mValue.equals(value))) %7B%0A      return;%0A    %7D%0A%0A    mValue = value;%0A%0A    for (OnValueChangeListener%3CT%3E listener : mListeners) %7B%0A      listener.onValueChange(this);%0A    %7D%0A  %7D%0A%0A  /**%0A   * Retrieves the current value%0A   *%0A   * @return the current value%0A   */%0A  T get() %7B%0A    return mValue;%0A  %7D%0A%0A  /**%0A   * Register a callback to be invoked when the value changes.%0A   *%0A   * @param listener The callback to invoke.%0A   */%0A  void attachListener(OnValueChangeListener%3CT%3E listener) %7B%0A    mListeners.add(listener);%0A  %7D%0A%0A  /**%0A   * Remove a callback.%0A   *%0A   * @param listener The listener to detach%0A   */%0A  void detach(OnValueChangeListener%3CT%3E listener) %7B%0A    mListeners.remove(listener);%0A  %7D%0A%0A  /** Interface definition for a callback to be invoked when value changes. */%0A  interface OnValueChangeListener%3CT%3E %7B%0A    /**%0A     * Called when a view has been clicked.%0A     *%0A     * @param value The dynamic value.%0A     */%0A    void onValueChange(DynamicValue%3CT%3E value);%0A  %7D%0A%7D%0A

introduce DynamicValue