Initial commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.thoughtworks.xstream.mapper;
|
||||
|
||||
import com.thoughtworks.xstream.core.util.FastField;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ElementIgnoringMapper extends MapperWrapper {
|
||||
static /* synthetic */ Class class$java$lang$Object;
|
||||
protected final Set fieldsToOmit;
|
||||
protected final Set unknownElementsToIgnore;
|
||||
|
||||
public ElementIgnoringMapper(Mapper mapper) {
|
||||
super(mapper);
|
||||
this.fieldsToOmit = new HashSet();
|
||||
this.unknownElementsToIgnore = new LinkedHashSet();
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class$(String str) {
|
||||
try {
|
||||
return Class.forName(str);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new NoClassDefFoundError().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object key(Class cls, String str) {
|
||||
return new FastField(cls, str);
|
||||
}
|
||||
|
||||
public void addElementsToIgnore(Pattern pattern) {
|
||||
this.unknownElementsToIgnore.add(pattern);
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.mapper.MapperWrapper, com.thoughtworks.xstream.mapper.Mapper
|
||||
public boolean isIgnoredElement(String str) {
|
||||
if (!this.unknownElementsToIgnore.isEmpty()) {
|
||||
Iterator it = this.unknownElementsToIgnore.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (((Pattern) it.next()).matcher(str).matches()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.isIgnoredElement(str);
|
||||
}
|
||||
|
||||
public void omitField(Class cls, String str) {
|
||||
this.fieldsToOmit.add(key(cls, str));
|
||||
}
|
||||
|
||||
@Override // com.thoughtworks.xstream.mapper.MapperWrapper, com.thoughtworks.xstream.mapper.Mapper
|
||||
public boolean shouldSerializeMember(Class cls, String str) {
|
||||
if (this.fieldsToOmit.contains(key(cls, str))) {
|
||||
return false;
|
||||
}
|
||||
Class cls2 = class$java$lang$Object;
|
||||
if (cls2 == null) {
|
||||
cls2 = class$("java.lang.Object");
|
||||
class$java$lang$Object = cls2;
|
||||
}
|
||||
if (cls == cls2 && isIgnoredElement(str)) {
|
||||
return false;
|
||||
}
|
||||
return super.shouldSerializeMember(cls, str);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user