本文整理汇总了Java中com.thoughtworks.xstream.annotations.XStreamImplicit类的典型用法代码示例。如果您正苦于以下问题:Java XStreamImplicit类的具体用法?Java XStreamImplicit怎么用?Java XStreamImplicit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XStreamImplicit类属于com.thoughtworks.xstream.annotations包,在下文中一共展示了XStreamImplicit类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processImplicitAnnotation
import com.thoughtworks.xstream.annotations.XStreamImplicit; //导入依赖的package包/类
private void processImplicitAnnotation(final Field field) {
final XStreamImplicit implicitAnnotation = field.getAnnotation(XStreamImplicit.class);
if (implicitAnnotation != null) {
if (implicitCollectionMapper == null) {
throw new InitializationException("No " + ImplicitCollectionMapper.class.getName() + " available");
}
final String fieldName = field.getName();
final String itemFieldName = implicitAnnotation.itemFieldName();
final String keyFieldName = implicitAnnotation.keyFieldName();
final boolean isMap = Map.class.isAssignableFrom(field.getType());
Class<?> itemType = null;
if (!field.getType().isArray()) {
final Type genericType = field.getGenericType();
if (genericType instanceof ParameterizedType) {
final Type[] actualTypeArguments = ((ParameterizedType)genericType).getActualTypeArguments();
final Type typeArgument = actualTypeArguments[isMap ? 1 : 0];
itemType = getClass(typeArgument);
}
}
if (isMap) {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemFieldName != null
&& !"".equals(itemFieldName) ? itemFieldName : null, itemType, keyFieldName != null
&& !"".equals(keyFieldName) ? keyFieldName : null);
} else {
if (itemFieldName != null && !"".equals(itemFieldName)) {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemFieldName, itemType);
} else {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemType);
}
}
}
}
示例2: processImplicitAnnotation
import com.thoughtworks.xstream.annotations.XStreamImplicit; //导入依赖的package包/类
private void processImplicitAnnotation(final Field field) {
final XStreamImplicit implicitAnnotation = field.getAnnotation(XStreamImplicit.class);
if (implicitAnnotation != null) {
if (implicitCollectionMapper == null) {
throw new InitializationException("No " + ImplicitCollectionMapper.class.getName() + " available");
}
final String fieldName = field.getName();
final String itemFieldName = implicitAnnotation.itemFieldName();
final String keyFieldName = implicitAnnotation.keyFieldName();
final boolean isMap = Map.class.isAssignableFrom(field.getType());
Class<?> itemType = null;
if (!field.getType().isArray()) {
final Type genericType = field.getGenericType();
if (genericType instanceof ParameterizedType) {
final Type[] actualTypeArguments = ((ParameterizedType)genericType).getActualTypeArguments();
final Type typeArgument = actualTypeArguments[isMap ? 1 : 0];
itemType = getClass(typeArgument);
}
}
if (isMap) {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemFieldName != null
&& !"".equals(itemFieldName) ? itemFieldName : null, itemType, keyFieldName != null
&& !"".equals(keyFieldName) ? keyFieldName : null);
} else {
if (itemFieldName != null && !"".equals(itemFieldName)) {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemFieldName, itemType);
} else {
implicitCollectionMapper.add(field.getDeclaringClass(), fieldName, itemType);
}
}
}
}
示例3: processImplicitAnnotation
import com.thoughtworks.xstream.annotations.XStreamImplicit; //导入依赖的package包/类
private void processImplicitAnnotation(Field paramField)
{
XStreamImplicit localXStreamImplicit = (XStreamImplicit)paramField.getAnnotation(XStreamImplicit.class);
if (localXStreamImplicit != null)
{
if (this.implicitCollectionMapper == null)
throw new InitializationException("No " + ImplicitCollectionMapper.class.getName() + " available");
String str1 = paramField.getName();
String str2 = localXStreamImplicit.itemFieldName();
String str3 = localXStreamImplicit.keyFieldName();
boolean bool1 = Map.class.isAssignableFrom(paramField.getType());
boolean bool2 = paramField.getType().isArray();
Class localClass1 = null;
if (!bool2)
{
Type localType = paramField.getGenericType();
boolean bool3 = localType instanceof ParameterizedType;
localClass1 = null;
if (bool3)
{
Type[] arrayOfType = ((ParameterizedType)localType).getActualTypeArguments();
int i;
if (bool1)
i = 1;
else
i = 0;
localClass1 = getClass(arrayOfType[i]);
}
}
if (bool1)
{
ImplicitCollectionMapper localImplicitCollectionMapper = this.implicitCollectionMapper;
Class localClass2 = paramField.getDeclaringClass();
String str4;
if ((str2 != null) && (!"".equals(str2)))
str4 = str2;
else
str4 = null;
Class localClass3 = localClass1;
String str5;
if ((str3 != null) && (!"".equals(str3)))
str5 = str3;
else
str5 = null;
localImplicitCollectionMapper.add(localClass2, str1, str4, localClass3, str5);
return;
}
if ((str2 != null) && (!"".equals(str2)))
{
this.implicitCollectionMapper.add(paramField.getDeclaringClass(), str1, str2, localClass1);
return;
}
this.implicitCollectionMapper.add(paramField.getDeclaringClass(), str1, localClass1);
}
}