/** * Constructor used by {@link BeanSerializerBuilder} to create an * instance * * @param type Nominal type of values handled by this serializer * @param builder Builder for accessing other collected information */ protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties) { super(type); _beanType = type; _props = properties; _filteredProps = filteredProperties; if (builder == null) { // mostly for testing _typeId = null; _anyGetterWriter = null; _propertyFilterId = null; _objectIdWriter = null; _serializationShape = null; } else { _typeId = builder.getTypeId(); _anyGetterWriter = builder.getAnyGetter(); _propertyFilterId = builder.getFilterId(); _objectIdWriter = builder.getObjectIdWriter(); JsonFormat.Value format = builder.getBeanDescription().findExpectedFormat(null); _serializationShape = (format == null) ? null : format.getShape(); } }
if (builder.getBeanDescription().getBeanClass().equals(Entity.class)){
@Override protected void processViews(SerializationConfig config, BeanSerializerBuilder builder) { super.processViews(config, builder); // ignore fields only for concrete class // note, that you can avoid or change this check Class<?> beanClass = builder.getBeanDescription().getBeanClass(); ClassUtil.ClassInfo classInfo = ClassUtil.getClassInfo(beanClass); // if (builder.getBeanDescription().getBeanClass().equals(Entity.class)) // { // get original writer List<BeanPropertyWriter> originalWriters = builder.getProperties(); // create actual writers List<BeanPropertyWriter> writers = new ArrayList<BeanPropertyWriter>(); String[] fs = this._getFilterFields(classInfo); for (BeanPropertyWriter writer : originalWriters) { final String propName = writer.getName(); // if it isn't ignored field, add to actual writers list boolean find = isFilterField( classInfo, propName, fs); if(!find){ writers.add(writer); } } builder.setProperties(writers); } }
@Override protected void processViews(SerializationConfig config, BeanSerializerBuilder builder) { super.processViews(config, builder); // ignore fields only for concrete class // note, that you can avoid or change this check Class<?> beanClass = builder.getBeanDescription().getBeanClass(); ClassUtil.ClassInfo classInfo = ClassUtil.getClassInfo(beanClass); // if (builder.getBeanDescription().getBeanClass().equals(Entity.class)) // { // get original writer List<BeanPropertyWriter> originalWriters = builder.getProperties(); // create actual writers List<BeanPropertyWriter> writers = new ArrayList<BeanPropertyWriter>(); String[] fs = this._getFilterFields(classInfo); for (BeanPropertyWriter writer : originalWriters) { final String propName = writer.getName(); // if it isn't ignored field, add to actual writers list boolean find = isFilterField( classInfo, propName, fs); if(!find){ writers.add(writer); } } builder.setProperties(writers); } }
/** * Constructor used by {@link BeanSerializerBuilder} to create an * instance * * @param type Nominal type of values handled by this serializer * @param builder Builder for accessing other collected information */ protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties) { super(type); _props = properties; _filteredProps = filteredProperties; if (builder == null) { // mostly for testing _typeId = null; _anyGetterWriter = null; _propertyFilterId = null; _objectIdWriter = null; _serializationShape = null; } else { _typeId = builder.getTypeId(); _anyGetterWriter = builder.getAnyGetter(); _propertyFilterId = builder.getFilterId(); _objectIdWriter = builder.getObjectIdWriter(); JsonFormat.Value format = builder.getBeanDescription().findExpectedFormat(null); _serializationShape = (format == null) ? null : format.getShape(); } }
/** * Constructor used by {@link BeanSerializerBuilder} to create an * instance * * @param type Nominal type of values handled by this serializer * @param builder Builder for accessing other collected information */ protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties) { super(type); _props = properties; _filteredProps = filteredProperties; if (builder == null) { // mostly for testing _typeId = null; _anyGetterWriter = null; _propertyFilterId = null; _objectIdWriter = null; _serializationShape = null; } else { _typeId = builder.getTypeId(); _anyGetterWriter = builder.getAnyGetter(); _propertyFilterId = builder.getFilterId(); _objectIdWriter = builder.getObjectIdWriter(); JsonFormat.Value format = builder.getBeanDescription().findExpectedFormat(null); _serializationShape = (format == null) ? null : format.getShape(); } }
/** * Constructor used by {@link BeanSerializerBuilder} to create an * instance * * @param type Nominal type of values handled by this serializer * @param builder Builder for accessing other collected information */ protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties) { super(type); _props = properties; _filteredProps = filteredProperties; if (builder == null) { // mostly for testing _typeId = null; _anyGetterWriter = null; _propertyFilterId = null; _objectIdWriter = null; _serializationShape = null; } else { _typeId = builder.getTypeId(); _anyGetterWriter = builder.getAnyGetter(); _propertyFilterId = builder.getFilterId(); _objectIdWriter = builder.getObjectIdWriter(); JsonFormat.Value format = builder.getBeanDescription().findExpectedFormat(null); _serializationShape = (format == null) ? null : format.getShape(); } }
/** * Constructor used by {@link BeanSerializerBuilder} to create an * instance * * @param type Nominal type of values handled by this serializer * @param builder Builder for accessing other collected information */ protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties) { super(type); _props = properties; _filteredProps = filteredProperties; if (builder == null) { // mostly for testing _typeId = null; _anyGetterWriter = null; _propertyFilterId = null; _objectIdWriter = null; _serializationShape = null; } else { _typeId = builder.getTypeId(); _anyGetterWriter = builder.getAnyGetter(); _propertyFilterId = builder.getFilterId(); _objectIdWriter = builder.getObjectIdWriter(); JsonFormat.Value format = builder.getBeanDescription().findExpectedFormat(null); _serializationShape = (format == null) ? null : format.getShape(); } }
/** * Constructor used by {@link BeanSerializerBuilder} to create an * instance * * @param type Nominal type of values handled by this serializer * @param builder Builder for accessing other collected information */ protected BeanSerializerBase(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties) { super(type); _beanType = type; _props = properties; _filteredProps = filteredProperties; if (builder == null) { // mostly for testing _typeId = null; _anyGetterWriter = null; _propertyFilterId = null; _objectIdWriter = null; _serializationShape = null; } else { _typeId = builder.getTypeId(); _anyGetterWriter = builder.getAnyGetter(); _propertyFilterId = builder.getFilterId(); _objectIdWriter = builder.getObjectIdWriter(); JsonFormat.Value format = builder.getBeanDescription().findExpectedFormat(null); _serializationShape = (format == null) ? null : format.getShape(); } }