Rabbit-R1/switch port/java/sources/com/airbnb/lottie/model/KeyPath.java
2024-05-21 17:08:36 -04:00

123 lines
3.6 KiB
Java

package com.airbnb.lottie.model;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/* loaded from: classes2.dex */
public class KeyPath {
public static final KeyPath COMPOSITION = new KeyPath("COMPOSITION");
private final List<String> keys;
private KeyPathElement resolvedElement;
public KeyPathElement getResolvedElement() {
return this.resolvedElement;
}
public KeyPath(String... strArr) {
this.keys = Arrays.asList(strArr);
}
private KeyPath(KeyPath keyPath) {
this.keys = new ArrayList(keyPath.keys);
this.resolvedElement = keyPath.resolvedElement;
}
public KeyPath addKey(String str) {
KeyPath keyPath = new KeyPath(this);
keyPath.keys.add(str);
return keyPath;
}
public KeyPath resolve(KeyPathElement keyPathElement) {
KeyPath keyPath = new KeyPath(this);
keyPath.resolvedElement = keyPathElement;
return keyPath;
}
public boolean matches(String str, int i) {
if (isContainer(str)) {
return true;
}
if (i >= this.keys.size()) {
return false;
}
return this.keys.get(i).equals(str) || this.keys.get(i).equals("**") || this.keys.get(i).equals("*");
}
public int incrementDepthBy(String str, int i) {
if (isContainer(str)) {
return 0;
}
if (this.keys.get(i).equals("**")) {
return (i != this.keys.size() - 1 && this.keys.get(i + 1).equals(str)) ? 2 : 0;
}
return 1;
}
public boolean fullyResolvesTo(String str, int i) {
if (i >= this.keys.size()) {
return false;
}
boolean z = i == this.keys.size() - 1;
String str2 = this.keys.get(i);
if (!str2.equals("**")) {
return (z || (i == this.keys.size() + (-2) && endsWithGlobstar())) && (str2.equals(str) || str2.equals("*"));
}
if (!z && this.keys.get(i + 1).equals(str)) {
return i == this.keys.size() + (-2) || (i == this.keys.size() + (-3) && endsWithGlobstar());
}
if (z) {
return true;
}
int i2 = i + 1;
if (i2 < this.keys.size() - 1) {
return false;
}
return this.keys.get(i2).equals(str);
}
public boolean propagateToChildren(String str, int i) {
return "__container".equals(str) || i < this.keys.size() - 1 || this.keys.get(i).equals("**");
}
private boolean isContainer(String str) {
return "__container".equals(str);
}
private boolean endsWithGlobstar() {
return this.keys.get(r1.size() - 1).equals("**");
}
public String keysToString() {
return this.keys.toString();
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
KeyPath keyPath = (KeyPath) obj;
if (!this.keys.equals(keyPath.keys)) {
return false;
}
KeyPathElement keyPathElement = this.resolvedElement;
if (keyPathElement != null) {
return keyPathElement.equals(keyPath.resolvedElement);
}
return keyPath.resolvedElement == null;
}
public int hashCode() {
int hashCode = this.keys.hashCode() * 31;
KeyPathElement keyPathElement = this.resolvedElement;
return hashCode + (keyPathElement != null ? keyPathElement.hashCode() : 0);
}
public String toString() {
return "KeyPath{keys=" + this.keys + ",resolved=" + (this.resolvedElement != null) + '}';
}
}