de.ingogriebsch.spring.hateoas.siren.AbstractSirenDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-hateoas-siren Show documentation
Show all versions of spring-hateoas-siren Show documentation
A library implementing Siren as a custom Spring HATEOAS hypermedia type. Siren is a hypermedia specification for representing entities.
The newest version!
/*-
* Copyright 2019-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.ingogriebsch.spring.hateoas.siren;
import static java.lang.String.format;
import static com.fasterxml.jackson.core.JsonToken.END_ARRAY;
import static com.fasterxml.jackson.core.JsonToken.START_ARRAY;
import static com.fasterxml.jackson.core.JsonToken.START_OBJECT;
import static com.fasterxml.jackson.databind.type.TypeFactory.defaultInstance;
import static com.google.common.collect.Lists.newArrayList;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.databind.deser.std.ContainerDeserializerBase;
import org.springframework.hateoas.RepresentationModel;
/**
* Base class supporting the implementation of deserializers which are able to deserialize a specific Siren entity into a
* {@link RepresentationModel}.
*
* @author Ingo Griebsch
* @since 1.0.0
*/
abstract class AbstractSirenDeserializer> extends ContainerDeserializerBase
implements ContextualDeserializer {
private static final long serialVersionUID = 3796755247545654672L;
protected final SirenDeserializerFacilities deserializerFacilities;
protected final SirenConfiguration configuration;
protected final JavaType contentType;
protected AbstractSirenDeserializer(SirenConfiguration configuration, SirenDeserializerFacilities deserializerFacilities,
JavaType contentType) {
super(contentType);
this.deserializerFacilities = deserializerFacilities;
this.configuration = configuration;
this.contentType = contentType;
}
@Override
public JavaType getContentType() {
return contentType;
}
@Override
public JsonDeserializer
© 2015 - 2025 Weber Informatics LLC | Privacy Policy