Initial commit
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package com.thoughtworks.xstream.converters.javabean;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BeanProperty {
|
||||
private static final Object[] EMPTY_ARGS = new Object[0];
|
||||
protected Method getter;
|
||||
private Class memberClass;
|
||||
private String propertyName;
|
||||
private Method setter;
|
||||
private Class type;
|
||||
|
||||
public BeanProperty(Class cls, String str, Class cls2) {
|
||||
this.memberClass = cls;
|
||||
this.propertyName = str;
|
||||
this.type = cls2;
|
||||
}
|
||||
|
||||
public Object get(Object obj) throws IllegalArgumentException, IllegalAccessException {
|
||||
if (isReadable()) {
|
||||
try {
|
||||
return this.getter.invoke(obj, EMPTY_ARGS);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new UndeclaredThrowableException(e.getTargetException());
|
||||
}
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Property ");
|
||||
stringBuffer.append(this.propertyName);
|
||||
stringBuffer.append(" of ");
|
||||
stringBuffer.append(this.memberClass);
|
||||
stringBuffer.append(" not readable");
|
||||
throw new IllegalStateException(stringBuffer.toString());
|
||||
}
|
||||
|
||||
public Class getBeanClass() {
|
||||
return this.memberClass;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.propertyName;
|
||||
}
|
||||
|
||||
public Class getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isReadable() {
|
||||
return this.getter != null;
|
||||
}
|
||||
|
||||
public boolean isWritable() {
|
||||
return this.setter != null;
|
||||
}
|
||||
|
||||
public Object set(Object obj, Object obj2) throws IllegalArgumentException, IllegalAccessException {
|
||||
if (isWritable()) {
|
||||
try {
|
||||
return this.setter.invoke(obj, obj2);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new UndeclaredThrowableException(e.getTargetException());
|
||||
}
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("Property ");
|
||||
stringBuffer.append(this.propertyName);
|
||||
stringBuffer.append(" of ");
|
||||
stringBuffer.append(this.memberClass);
|
||||
stringBuffer.append(" not writable");
|
||||
throw new IllegalStateException(stringBuffer.toString());
|
||||
}
|
||||
|
||||
public void setGetterMethod(Method method) {
|
||||
this.getter = method;
|
||||
}
|
||||
|
||||
public void setSetterMethod(Method method) {
|
||||
this.setter = method;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user