org.codehaus.jackson.map.ser.BeanPropertyWriter Java Examples

The following examples show how to use org.codehaus.jackson.map.ser.BeanPropertyWriter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JsonTopologySerializer.java    From libcrunch with Apache License 2.0 6 votes vote down vote up
public void setupModule(SetupContext context) {
  context.addBeanSerializerModifier(new BeanSerializerModifier() {
    @Override
    public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
      BasicBeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
      ListIterator<BeanPropertyWriter> it = beanProperties.listIterator();
      while (it.hasNext()) {
        BeanPropertyWriter writer = it.next();
        // replace the bean writer with my own if it is for "failed"
        if (writer.getName().equals("failed")) {
          BeanPropertyWriter newWriter = new IsFailedWriter(writer);
          it.set(newWriter);
        }
      }
      return beanProperties;
    }
  });
}
 
Example #2
Source File: TaggedLogAPIEntity.java    From Eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider provider, BeanPropertyWriter writer) throws Exception {
	if(bean instanceof TaggedLogAPIEntity){
		TaggedLogAPIEntity entity = (TaggedLogAPIEntity) bean;
		Set<String> modified = entity.modifiedQualifiers();
		Set<String> basePropertyNames = getPropertyNames();
		String writerName = writer.getName();
		if(modified.contains(writerName) || basePropertyNames.contains(writerName)){
			if((!entity.isSerializeVerbose() && verboseFields.contains(writerName))||							// skip verbose fields
					(timestamp.equals(writerName) && !EntityDefinitionManager.isTimeSeries(entity.getClass()))	// skip timestamp for non-timeseries entity
			){
				// log skip
				if(LOG.isDebugEnabled()) LOG.debug("skip field");
			}else{
				// if serializeAlias is not null and exp is not null
				if (exp.equals(writerName) && entity.getSerializeAlias()!=null && entity.getExp()!=null) {
					Map<String, Object> _exp = new HashMap<String, Object>();
					for (Map.Entry<String, Object> entry : entity.getExp().entrySet()) {
						String alias = entity.getSerializeAlias().get(entry.getKey());
						if (alias != null) {
							_exp.put(alias, entry.getValue());
						} else {
							_exp.put(entry.getKey(), entry.getValue());
						}
					}
					entity.setExp(_exp);
				}
				// write included field into serialized json output
				writer.serializeAsField(bean, jgen, provider);
			}
		}
	}else{
		writer.serializeAsField(bean, jgen, provider);
	}
}
 
Example #3
Source File: Jackson1Parser.java    From typescript-generator with MIT License 4 votes vote down vote up
public BeanPropertyWriter[] getProperties() {
    return _props;
}
 
Example #4
Source File: JsonTopologySerializer.java    From libcrunch with Apache License 2.0 4 votes vote down vote up
public IsFailedWriter(BeanPropertyWriter base) {
  super(base);
}
 
Example #5
Source File: JsonTopologySerializer.java    From libcrunch with Apache License 2.0 4 votes vote down vote up
public IsFailedWriter(BeanPropertyWriter base, JsonSerializer<Object> ser) {
  super(base, ser);
}
 
Example #6
Source File: JsonTopologySerializer.java    From libcrunch with Apache License 2.0 4 votes vote down vote up
@Override
public BeanPropertyWriter withSerializer(JsonSerializer<Object> ser) {
  return new IsFailedWriter(this, ser);
}