
com.qmetric.hal.reader.HalReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of halreader Show documentation
Show all versions of halreader Show documentation
HAL+JSON library wrapper for HalBuilder (https://github.com/HalBuilder)
package com.qmetric.hal.reader;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.theoryinpractise.halbuilder.api.ReadableRepresentation;
import com.theoryinpractise.halbuilder.api.RepresentationFactory;
import java.io.Reader;
/**
* Hal reader used for reading HAL resources
*/
public class HalReader
{
private final ObjectMapper objectMapper;
private final RepresentationFactory representationFactory;
/**
* Construct new instance with default com.fasterxml.jackson.databind.ObjectMapper used for parsing HAL resource properties.
*/
public HalReader()
{
this(new ObjectMapper());
}
/**
* Construct new instance with given com.fasterxml.jackson.databind.ObjectMapper used for parsing HAL resource properties.
* @param objectMapper Jackson object mapper
*/
public HalReader(final ObjectMapper objectMapper)
{
this.objectMapper = objectMapper;
this.representationFactory = new JsonRepresentationFactory();
}
/**
* Read and return HalResource
* @param reader Reader
* @return Hal resource
*/
public HalResource read(final Reader reader)
{
final ReadableRepresentation readableRepresentation = representationFactory.readRepresentation(reader);
return new HalResource(objectMapper, readableRepresentation);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy