本文整理匯總了Java中org.codehaus.jackson.annotate.JsonIgnoreProperties類的典型用法代碼示例。如果您正苦於以下問題:Java JsonIgnoreProperties類的具體用法?Java JsonIgnoreProperties怎麽用?Java JsonIgnoreProperties使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
JsonIgnoreProperties類屬於org.codehaus.jackson.annotate包,在下文中一共展示了JsonIgnoreProperties類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findIgnoreUnknownProperties
import org.codehaus.jackson.annotate.JsonIgnoreProperties; //導入依賴的package包/類
public Boolean findIgnoreUnknownProperties(AnnotatedClass paramAnnotatedClass)
{
JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotatedClass.getAnnotation(JsonIgnoreProperties.class);
if (localJsonIgnoreProperties == null)
return null;
return Boolean.valueOf(localJsonIgnoreProperties.ignoreUnknown());
}
示例2: findPropertiesToIgnore
import org.codehaus.jackson.annotate.JsonIgnoreProperties; //導入依賴的package包/類
public String[] findPropertiesToIgnore(AnnotatedClass paramAnnotatedClass)
{
JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotatedClass.getAnnotation(JsonIgnoreProperties.class);
if (localJsonIgnoreProperties == null)
return null;
return localJsonIgnoreProperties.value();
}
示例3: createMixInAnnotation
import org.codehaus.jackson.annotate.JsonIgnoreProperties; //導入依賴的package包/類
/**
* 創建jackson的代理注解接口類 <br>
* 2013-10-25 上午11:59:50
*
* @param names 要生成的字段
* @return 代理接口類
*/
private Class<?> createMixInAnnotation(String[] names) {
Class<?> clazz = null;
clazz = proxyMixInAnnotationMap.get(StringHelper.hashCodeOfStringArray(names));
if (clazz != null) {
return clazz;
}
ClassPool pool = ClassPool.getDefault();
// 創建代理接口
CtClass cc = pool.makeInterface("ProxyMixInAnnotation" + System.currentTimeMillis()
+ proxyIndex++);
ClassFile ccFile = cc.getClassFile();
ConstPool constpool = ccFile.getConstPool();
// create the annotation
AnnotationsAttribute attr = new AnnotationsAttribute(constpool,
AnnotationsAttribute.visibleTag);
// 創建JsonIgnoreProperties注解
Annotation jsonIgnorePropertiesAnnotation = new Annotation(
JsonIgnoreProperties.class.getName(), constpool);
BooleanMemberValue ignoreUnknownMemberValue = new BooleanMemberValue(false, constpool);
ArrayMemberValue arrayMemberValue = new ArrayMemberValue(constpool);// value的數組成員
Collection<MemberValue> memberValues = new HashSet<MemberValue>();
for (int i = 0; i < names.length; i++) {
String name = names[i];
StringMemberValue memberValue = new StringMemberValue(constpool);// 將name值設入注解內
memberValue.setValue(name);
memberValues.add(memberValue);
}
arrayMemberValue.setValue(memberValues.toArray(new MemberValue[]{}));
jsonIgnorePropertiesAnnotation.addMemberValue("value", arrayMemberValue);
jsonIgnorePropertiesAnnotation.addMemberValue("ignoreUnknown", ignoreUnknownMemberValue);
attr.addAnnotation(jsonIgnorePropertiesAnnotation);
ccFile.addAttribute(attr);
// generate the class
try {
clazz = cc.toClass();
proxyMixInAnnotationMap.put(StringHelper.hashCodeOfStringArray(names), clazz);
// JsonIgnoreProperties ignoreProperties = (JsonIgnoreProperties)
// clazz
// .getAnnotation(JsonIgnoreProperties.class);
// EntityHelper.print(ignoreProperties);
//
// EntityHelper.print(clazz);
// try {
// Object instance = clazz.newInstance();
// EntityHelper.print(instance);
//
// } catch (InstantiationException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
} catch (CannotCompileException e) {
e.printStackTrace();
}
// right
// mthd.getMethodInfo().addAttribute(attr);
return clazz;
}