Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing parentheses in reference documentation #364

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>4.0.9.RELEASE</spring.version>
<logback.version>1.1.2</logback.version>
<jackson.version>2.4.3</jackson.version>
<logback.version>1.1.3</logback.version>
<jackson.version>2.4.6</jackson.version>
<jaxrs.version>1.0</jaxrs.version>
<minidevjson.version>2.1.0</minidevjson.version>
<minidevjson.version>2.1.1</minidevjson.version>
<jsonpath.version>0.9.1</jsonpath.version>
<slf4j.version>1.7.10</slf4j.version>
<slf4j.version>1.7.12</slf4j.version>
<evo.version>1.2.1</evo.version>
<bundlor.failOnWarnings>true</bundlor.failOnWarnings>
<source.level>1.6</source.level>
Expand All @@ -88,7 +88,7 @@
<profile>
<id>spring41</id>
<properties>
<spring.version>4.1.5.RELEASE</spring.version>
<spring.version>4.1.6.RELEASE</spring.version>
</properties>
</profile>

Expand Down Expand Up @@ -130,7 +130,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<version>2.10.3</version>
<executions>
<execution>
<goals>
Expand Down Expand Up @@ -167,7 +167,7 @@
<dependency>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-build-resources</artifactId>
<version>1.5.2.RELEASE</version>
<version>1.6.0.RELEASE</version>
<scope>provided</scope>
<type>zip</type>
</dependency>
Expand Down Expand Up @@ -305,7 +305,7 @@

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<version>1.8</version>
<executions>

<execution>
Expand Down Expand Up @@ -355,7 +355,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<version>2.5.4</version>
<executions>
<execution>
<id>static</id>
Expand All @@ -377,7 +377,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-5</version>
<version>1.0</version>
<configuration>
<fromDir>${project.build.directory}</fromDir>
</configuration>
Expand Down Expand Up @@ -593,7 +593,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.3</version>
<configuration>
<source>${source.level}</source>
<target>${source.level}</target>
Expand All @@ -620,7 +620,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<version>2.6</version>
<configuration>
<useDefaultManifestFile>true</useDefaultManifestFile>
</configuration>
Expand All @@ -643,7 +643,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<version>2.10.3</version>
<configuration>
<breakiterator>true</breakiterator>
<header>${project.name}</header>
Expand All @@ -661,7 +661,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.1</version>
<version>2.8.2</version>
<configuration>
<skip>true</skip>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ You can also easily access links contained in that resource:
[source, java]
----
Link selfLink = new Link("http://myhost/people");
assertThat(resource.getId(), is(selfLink);
assertThat(resource.getId(), is(selfLink));
assertThat(resource.getLink(Link.SELF), is(selfLink));
----
[[fundamentals.obtaining-links]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2015 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.
Expand All @@ -15,6 +15,8 @@
*/
package org.springframework.hateoas.mvc;

import java.lang.reflect.Type;

import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.util.Assert;
Expand All @@ -24,7 +26,7 @@
/**
* Extension of {@link MappingJackson2HttpMessageConverter} to constrain the ability to read and write HTTP message
* based on the target type. Useful in case the {@link ObjectMapper} about to be configured has customizations that
* sholny be applied to object trees of a certain base type.
* shall only be applied to object trees of a certain base type.
*
* @author Oliver Gierke
*/
Expand Down Expand Up @@ -52,6 +54,16 @@ public boolean canRead(Class<?> clazz, MediaType mediaType) {
return type.isAssignableFrom(clazz) && super.canRead(clazz, mediaType);
}

/*
* (non-Javadoc)
* @see org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#canRead(java.lang.reflect.Type, java.lang.Class, org.springframework.http.MediaType)
*/
@Override
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
return this.type.isAssignableFrom(getJavaType(type, contextClass).getRawClass())
&& super.canRead(type, contextClass, mediaType);
}

/*
* (non-Javadoc)
* @see org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#canWrite(java.lang.Class, org.springframework.http.MediaType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2015 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.
Expand All @@ -17,12 +17,12 @@

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.springframework.http.MediaType.*;

import org.junit.Test;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.GenericHttpMessageConverter;

/**
* Unit tests for {@link TypeConstrainedMappingJackson2HttpMessageConverter}.
Expand All @@ -40,30 +40,41 @@ public void rejectsNullType() {
}

/**
* @see #219
* @see #219, #360
*/
@Test
public void canReadTypeIfAssignableToConfiguredType() {

HttpMessageConverter<Object> converter = new TypeConstrainedMappingJackson2HttpMessageConverter(
GenericHttpMessageConverter<Object> converter = new TypeConstrainedMappingJackson2HttpMessageConverter(
ResourceSupport.class);

assertThat(converter.canRead(Object.class, MediaType.APPLICATION_JSON), is(false));
assertThat(converter.canRead(ResourceSupport.class, MediaType.APPLICATION_JSON), is(true));
assertThat(converter.canRead(Resource.class, MediaType.APPLICATION_JSON), is(true));
assertCanRead(converter, Object.class, false);
assertCanRead(converter, ResourceSupport.class, true);
assertCanRead(converter, Resource.class, true);
}

/**
* @see #219
* @see #219, #360
*/
@Test
public void canWriteTypeIfAssignableToConfiguredType() {

HttpMessageConverter<Object> converter = new TypeConstrainedMappingJackson2HttpMessageConverter(
GenericHttpMessageConverter<Object> converter = new TypeConstrainedMappingJackson2HttpMessageConverter(
ResourceSupport.class);

assertThat(converter.canWrite(Object.class, MediaType.APPLICATION_JSON), is(false));
assertThat(converter.canWrite(ResourceSupport.class, MediaType.APPLICATION_JSON), is(true));
assertThat(converter.canWrite(Resource.class, MediaType.APPLICATION_JSON), is(true));
assertCanWrite(converter, Object.class, false);
assertCanWrite(converter, ResourceSupport.class, true);
assertCanWrite(converter, Resource.class, true);
}

private static void assertCanRead(GenericHttpMessageConverter<Object> converter, Class<?> type, boolean expected) {

assertThat(converter.canRead(type, APPLICATION_JSON), is(expected));
assertThat(converter.canRead(type, type, APPLICATION_JSON), is(expected));
}

private static void assertCanWrite(GenericHttpMessageConverter<Object> converter, Class<?> type, boolean expected) {

assertThat(converter.canWrite(type, APPLICATION_JSON), is(expected));
}
}