// Path: library/src/main/java/info/dourok/esactivity/function/Function.java
// @FunctionalInterface
// public interface Function<T, R> {
// 
//   /**
//    * Applies this function to the given argument.
//    *
//    * @param t the function argument
//    * @return the function result
//    */
//   R apply(T t);
//   /**
//    * Returns a function that always returns its input argument.
//    *
//    * @param <T> the type of the input and output objects to the function
//    * @return a function that always returns its input argument
//    */
//   static <T> Function<T, T> identity() {
//     return t -> t;
//   }
// }


import android.app.Activity;
import android.app.Fragment;
import android.support.v4.app.FragmentActivity;
import info.dourok.esactivity.function.Function;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static android.view.View.NO_ID;
package info.dourok.esactivity.reference;



/**
 * @author tiaolins
 * @date 2018/3/3.
 */
public class FragmentReferenceUpdater extends AbstractActivityReferenceUpdater {
  private Map<Field, Function<Activity, Object>> map = new HashMap<>(4);

  /** 缓存 Fragment Finder. fragment makeInactive 之后状态会被清空，所以得提前对 Fragment 的 id 或 tag 进行保存。 */
  @Override
  public void beforeAdd(Object lambda) {
    Class zlass = lambda.getClass();
    for (Field field : zlass.getDeclaredFields()) {
      field.setAccessible(true);
      try {
// Path: library/src/main/java/info/dourok/esactivity/function/Function.java
// @FunctionalInterface
// public interface Function<T, R> {
// 
//   /**
//    * Applies this function to the given argument.
//    *
//    * @param t the function argument
//    * @return the function result
//    */
//   R apply(T t);
//   /**
//    * Returns a function that always returns its input argument.
//    *
//    * @param <T> the type of the input and output objects to the function
//    * @return a function that always returns its input argument
//    */
//   static <T> Function<T, T> identity() {
//     return t -> t;
//   }
// }


// Path: library/src/main/java/info/dourok/esactivity/reference/FragmentReferenceUpdater.java
import android.app.Activity;
import android.app.Fragment;
import android.support.v4.app.FragmentActivity;
import info.dourok.esactivity.function.Function;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static android.view.View.NO_ID;

package info.dourok.esactivity.reference;



/**
 * @author tiaolins
 * @date 2018/3/3.
 */
public class FragmentReferenceUpdater extends AbstractActivityReferenceUpdater {
  private Map<Field, Function<Activity, Object>> map = new HashMap<>(4);

  /** 缓存 Fragment Finder. fragment makeInactive 之后状态会被清空，所以得提前对 Fragment 的 id 或 tag 进行保存。 */
  @Override
  public void beforeAdd(Object lambda) {
    Class zlass = lambda.getClass();
    for (Field field : zlass.getDeclaredFields()) {
      field.setAccessible(true);
      try {
        Function<Activity, Object> fragmentFinder = null;