Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2014. Escalon System-Entwicklung, Dietrich Schulten
*
* 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
*
* http://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.escalon.hypermedia.spring.hydra;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.BeanSerializerFactory;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.fasterxml.jackson.databind.util.NameTransformer;
import de.escalon.hypermedia.hydra.serialize.*;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedResources;
import java.io.IOException;
import java.util.*;
import static de.escalon.hypermedia.hydra.serialize.JacksonHydraSerializer.KEY_LD_CONTEXT;
/**
* Serializer for Resources. Created by dschulten on 15.09.2014.
*/
@SuppressWarnings("unused")
public class PagedResourcesSerializer extends StdSerializer {
private final static Set navigationRels = new HashSet();
static {
Collections.addAll(navigationRels, Link.REL_FIRST, Link.REL_NEXT, Link.REL_PREVIOUS, Link.REL_LAST);
}
private final LdContextFactory ldContextFactory;
private final ProxyUnwrapper proxyUnwrapper;
@SuppressWarnings("unused")
public PagedResourcesSerializer(ProxyUnwrapper proxyUnwrapper) {
super(PagedResources.class);
this.ldContextFactory = new LdContextFactory();
this.proxyUnwrapper = proxyUnwrapper;
ldContextFactory.setProxyUnwrapper(proxyUnwrapper);
}
@Override
public void serialize(PagedResources pagedResources, JsonGenerator jgen, SerializerProvider serializerProvider) throws
IOException {
final SerializationConfig config = serializerProvider.getConfig();
JavaType javaType = config.constructType(pagedResources.getClass());
JsonSerializer