// Path: src/main/java/com/google/android/apps/common/testing/accessibility/framework/replacements/TextUtils.java
// public class TextUtils {
//   private TextUtils() {
//     // Not instantiable
//   }
// 
//   /**
//    * @see android.text.TextUtils#isEmpty(CharSequence)
//    */
//   @EnsuresNonNullIf(expression = "#1", result = false)
//   public static boolean isEmpty(@Nullable CharSequence str) {
//     return (str == null) || (str.length() == 0);
//   }
// 
//   /** See {@link android.text.TextUtils#getTrimmedLength(CharSequence)}. */
//   public static int getTrimmedLength(CharSequence str) {
//     return str.toString().trim().length();
//   }
// 
//   /** See {@link android.text.TextUtils#equals(CharSequence, CharSequence)}. */
//   public static boolean equals(@Nullable CharSequence s1, @Nullable CharSequence s2) {
//     if (s1 == s2) {
//       return true;
//     }
// 
//     if ((s1 != null) && (s2 != null) && (s1.length() == s2.length())) {
//       if (s1 instanceof String && s2 instanceof String) {
//         return ((String) s1).equals((String) s2);
//       } else {
//         for (int i = 0; i < s1.length(); i++) {
//           if (s1.charAt(i) != s2.charAt(i)) {
//             return false;
//           }
//         }
//         return true;
//       }
//     }
//     return false;
//   }
// }


import com.google.android.apps.common.testing.accessibility.framework.replacements.TextUtils;
import com.google.android.apps.common.testing.accessibility.framework.uielement.proto.AccessibilityHierarchyProtos.ViewHierarchyActionProto;
import org.checkerframework.checker.nullness.qual.Nullable;
package com.google.android.apps.common.testing.accessibility.framework.uielement;


/**
 * Representation of {@code AccessibilityNodeInfo.AccessibilityAction} in a {@code View}.
 *
 * <p>The action exists within {@code ViewHierarchyElement} and it is one-to-one map from {@code
 * AccessibilityAction}.
 */
public class ViewHierarchyAction {
  private final int actionId;
  private final @Nullable CharSequence actionLabel;

  protected ViewHierarchyAction(int actionId, @Nullable CharSequence actionLabel) {
    this.actionId = actionId;
    this.actionLabel = actionLabel;
  }

  ViewHierarchyAction(ViewHierarchyActionProto proto) {
    this.actionId = proto.getActionId();
    this.actionLabel = proto.hasActionLabel() ? proto.getActionLabel() : null;
  }

  /**
   * Returns the action Id. Action Id will be one of the actions that are listed in {@code
   * AccessibilityNodeInfo}.
   */
  int getActionId() {
    return actionId;
  }

  /** Returns the label of the corresponding action id. */
  @Nullable
  CharSequence getActionLabel() {
    return actionLabel;
  }

  ViewHierarchyActionProto toProto() {
    ViewHierarchyActionProto.Builder builder = ViewHierarchyActionProto.newBuilder();

    builder.setActionId(actionId);
// Path: src/main/java/com/google/android/apps/common/testing/accessibility/framework/replacements/TextUtils.java
// public class TextUtils {
//   private TextUtils() {
//     // Not instantiable
//   }
// 
//   /**
//    * @see android.text.TextUtils#isEmpty(CharSequence)
//    */
//   @EnsuresNonNullIf(expression = "#1", result = false)
//   public static boolean isEmpty(@Nullable CharSequence str) {
//     return (str == null) || (str.length() == 0);
//   }
// 
//   /** See {@link android.text.TextUtils#getTrimmedLength(CharSequence)}. */
//   public static int getTrimmedLength(CharSequence str) {
//     return str.toString().trim().length();
//   }
// 
//   /** See {@link android.text.TextUtils#equals(CharSequence, CharSequence)}. */
//   public static boolean equals(@Nullable CharSequence s1, @Nullable CharSequence s2) {
//     if (s1 == s2) {
//       return true;
//     }
// 
//     if ((s1 != null) && (s2 != null) && (s1.length() == s2.length())) {
//       if (s1 instanceof String && s2 instanceof String) {
//         return ((String) s1).equals((String) s2);
//       } else {
//         for (int i = 0; i < s1.length(); i++) {
//           if (s1.charAt(i) != s2.charAt(i)) {
//             return false;
//           }
//         }
//         return true;
//       }
//     }
//     return false;
//   }
// }


// Path: src/main/java/com/google/android/apps/common/testing/accessibility/framework/uielement/ViewHierarchyAction.java
import com.google.android.apps.common.testing.accessibility.framework.replacements.TextUtils;
import com.google.android.apps.common.testing.accessibility.framework.uielement.proto.AccessibilityHierarchyProtos.ViewHierarchyActionProto;
import org.checkerframework.checker.nullness.qual.Nullable;

package com.google.android.apps.common.testing.accessibility.framework.uielement;


/**
 * Representation of {@code AccessibilityNodeInfo.AccessibilityAction} in a {@code View}.
 *
 * <p>The action exists within {@code ViewHierarchyElement} and it is one-to-one map from {@code
 * AccessibilityAction}.
 */
public class ViewHierarchyAction {
  private final int actionId;
  private final @Nullable CharSequence actionLabel;

  protected ViewHierarchyAction(int actionId, @Nullable CharSequence actionLabel) {
    this.actionId = actionId;
    this.actionLabel = actionLabel;
  }

  ViewHierarchyAction(ViewHierarchyActionProto proto) {
    this.actionId = proto.getActionId();
    this.actionLabel = proto.hasActionLabel() ? proto.getActionLabel() : null;
  }

  /**
   * Returns the action Id. Action Id will be one of the actions that are listed in {@code
   * AccessibilityNodeInfo}.
   */
  int getActionId() {
    return actionId;
  }

  /** Returns the label of the corresponding action id. */
  @Nullable
  CharSequence getActionLabel() {
    return actionLabel;
  }

  ViewHierarchyActionProto toProto() {
    ViewHierarchyActionProto.Builder builder = ViewHierarchyActionProto.newBuilder();

    builder.setActionId(actionId);
    if (!TextUtils.isEmpty(actionLabel)) {