Spring Framework MappingJacksonValue - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MappingJacksonValue class.

This code example shows how to use the following methods:getSerializationView, getValue, setSerializationView
		Class<?> serializationView = null; 
		Object value = object; 
 
		if (value instanceof MappingJacksonValue) { 
			MappingJacksonValue container = (MappingJacksonValue) value; 
			value = container.getValue(); 
			serializationView = container.getSerializationView(); 
		} 
		if (serializationView != null) { 
			this.objectMapper.writerWithView(serializationView).writeValue(generator, value); 
		} 
		else { 
			this.objectMapper.writeValue(generator, value); 
		} 
		writeSuffix(generator, object); 
		generator.flush(); 
	} 
 
	/** 
	 * Write a prefix before the main content. 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	public final Object beforeBodyWrite(Object body, MethodParameter returnType,
			MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType,
			ServerHttpRequest request, ServerHttpResponse response) {
 
		MappingJacksonValue container = getOrCreateContainer(body);
		beforeBodyWriteInternal(container, contentType, returnType, request, response);
		return container;
	} 
 
	/** 
	 * Wrap the body in a {@link MappingJacksonValue} value container (for providing 
	 * additional serialization instructions) or simply cast it if already wrapped. 
	 */ 
	protected MappingJacksonValue getOrCreateContainer(Object body) {
		return (body instanceof MappingJacksonValue ? (MappingJacksonValue) body : new MappingJacksonValue(body));
	} 
 
	/** 
	 * Invoked only if the converter type is {@code MappingJackson2HttpMessageConverter}. 
	 */ 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setSerializationView
		Class<?>[] classes = annotation.value();
		if (classes.length != 1) {
			throw new IllegalArgumentException(
					"@JsonView only supported for response body advice with exactly 1 class argument: " + returnType);
		} 
		bodyContainer.setSerializationView(classes[0]);
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getJsonpFunction
		if (this.jsonPrefix != null) { 
			generator.writeRaw(this.jsonPrefix); 
		} 
		String jsonpFunction = null; 
		if (object instanceof MappingJacksonValue) { 
			jsonpFunction = ((MappingJacksonValue)object).getJsonpFunction(); 
		} 
		if (jsonpFunction != null) { 
			generator.writeRaw(jsonpFunction + "(" ); 
		} 
	} 
 
	@Override 
	protected void writeSuffix(JsonGenerator generator, Object object) throws IOException { 
		String jsonpFunction = null; 
		if (object instanceof MappingJacksonValue) { 
			jsonpFunction = ((MappingJacksonValue)object).getJsonpFunction(); 
		} 
		if (jsonpFunction != null) { 
			generator.writeRaw(");"); 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework MappingJacksonValue Methods: