All Downloads are FREE. Search and download functionalities are using the official Maven repository.

internal.org.springframework.content.rest.mappingcontext.ContentPropertyToLinkrelMappingContext Maven / Gradle / Ivy

There is a newer version: 3.0.15
Show newest version
package internal.org.springframework.content.rest.mappingcontext;

import org.springframework.content.commons.mappingcontext.ClassWalker;

import java.util.HashMap;
import java.util.Map;

public class ContentPropertyToLinkrelMappingContext {

    private Map, Map> mappings = new HashMap, Map>();

    public ContentPropertyToLinkrelMappingContext() {}

    public Map getMappings(Class domainClass) {

        Map mappings = this.mappings.get(domainClass);
        if (mappings == null) {
            mappings = resolveMappings(domainClass);
        }
        return mappings;
    }

    private Map resolveMappings(Class domainClass) {
        RestResourceMappingBuilder visitor = new RestResourceMappingBuilder((rr)->rr.linkRel());
        ClassWalker walker = new ClassWalker(visitor);
        walker.accept(domainClass);
        Map mappings = visitor.getMappings();
        this.mappings.put(domainClass, mappings);
        return mappings;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy