List of usage examples for com.fasterxml.jackson.databind.introspect AnnotatedMember getValue
public abstract Object getValue(Object paramObject);
From source file:org.jongo.marshall.jackson.JacksonObjectIdUpdater.java
public void setObjectId(Object target, ObjectId id) { for (BeanPropertyDefinition def : beanDescription(target.getClass()).findProperties()) { if (isIdProperty(def)) { AnnotatedMember accessor = def.getAccessor(); accessor.fixAccess();/*from w w w. ja va 2 s . c om*/ if (accessor.getValue(target) != null) { throw new IllegalArgumentException("Unable to set objectid on class: " + target.getClass()); } AnnotatedMember field = def.getField(); field.fixAccess(); Class<?> type = field.getRawType(); if (ObjectId.class.isAssignableFrom(type)) { field.setValue(target, id); } else if (type.equals(String.class) && isObjectId(def)) { field.setValue(target, id.toString()); } return; } } }
From source file:org.jongo.marshall.jackson.JacksonObjectIdUpdater.java
public Object getId(Object pojo) { BasicBeanDescription beanDescription = beanDescription(pojo.getClass()); for (BeanPropertyDefinition def : beanDescription.findProperties()) { if (isIdProperty(def)) { AnnotatedMember accessor = def.getAccessor(); accessor.fixAccess();/*from w w w. j ava2 s . c om*/ Object id = accessor.getValue(pojo); if (id instanceof String && isObjectId(def)) { return new ObjectId(id.toString()); } else { return id; } } } return null; }
From source file:org.jongo.marshall.jackson.JacksonObjectIdUpdater.java
public boolean mustGenerateObjectId(Object pojo) { for (BeanPropertyDefinition def : beanDescription(pojo.getClass()).findProperties()) { if (isIdProperty(def)) { AnnotatedMember accessor = def.getAccessor(); accessor.fixAccess();//from w ww . j av a 2 s.com return isObjectId(def) && accessor.getValue(pojo) == null; } } return false; }