#831 - Polishing.
Applied some recommendations provided by IntelliJ that I stumbled over while reviewing the changes.
This commit is contained in:
@@ -166,7 +166,7 @@ public class JsonPathLinkDiscoverer implements LinkDiscoverer {
|
||||
JSONArray jsonArray = (JSONArray) parseResult;
|
||||
|
||||
return jsonArray.stream() //
|
||||
.flatMap(it -> JSONArray.class.isInstance(it) ? ((JSONArray) it).stream() : Stream.of(it)) //
|
||||
.flatMap(it -> it instanceof JSONArray ? ((JSONArray) it).stream() : Stream.of(it)) //
|
||||
.map(it -> extractLink(it, rel)) //
|
||||
.collect(Collectors.collectingAndThen(Collectors.toList(), Links::of));
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Traverson {
|
||||
Traverson.class.getClassLoader());
|
||||
|
||||
Assert.isTrue(ALL_DEFAULTS.size() == 1,
|
||||
() -> String.format("Expected to find only one TraversonDefaults instance, but found: ", //
|
||||
() -> String.format("Expected to find only one TraversonDefaults instance, but found: %s", //
|
||||
ALL_DEFAULTS.stream() //
|
||||
.map(Object::getClass) //
|
||||
.map(Class::getName) //
|
||||
|
||||
@@ -54,7 +54,7 @@ class HypermediaConfigurationImportSelector implements ImportSelector {
|
||||
|
||||
// No additional filtering needed.
|
||||
if (types.isEmpty()) {
|
||||
return configurationProviders.toArray(new String[configurationProviders.size()]);
|
||||
return configurationProviders.toArray(new String[0]);
|
||||
}
|
||||
|
||||
// Filter the ones supporting the given media types
|
||||
|
||||
@@ -110,7 +110,7 @@ class WebMvcHateoasConfiguration {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
if (!RestTemplate.class.isInstance(bean)) {
|
||||
if (!(bean instanceof RestTemplate)) {
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,6 @@ class WebStackImportSelector implements ImportSelector {
|
||||
imports.add("org.springframework.hateoas.config.WebFluxHateoasConfiguration");
|
||||
}
|
||||
|
||||
return imports.toArray(new String[imports.size()]);
|
||||
return imports.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class CollectionJsonLinkDiscoverer extends JsonPathLinkDiscoverer {
|
||||
return findSelfLink(representation) //
|
||||
.map(Links::of) //
|
||||
.map(it -> it.and(links)) //
|
||||
.orElseGet(() -> links);
|
||||
.orElse(links);
|
||||
}
|
||||
|
||||
private Links addSelfLink(Links links, InputStream representation) {
|
||||
@@ -128,7 +128,7 @@ public class CollectionJsonLinkDiscoverer extends JsonPathLinkDiscoverer {
|
||||
return findSelfLink(representation) //
|
||||
.map(Links::of) //
|
||||
.map(it -> it.and(links)) //
|
||||
.orElseGet(() -> links);
|
||||
.orElse(links);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -798,7 +798,7 @@ class Jackson2CollectionJsonModule extends SimpleModule {
|
||||
|
||||
return resources.getContent().stream().map(content -> {
|
||||
|
||||
if (!EntityModel.class.isInstance(content)) {
|
||||
if (!(content instanceof EntityModel)) {
|
||||
return new CollectionJsonItem<>().withRawData(content);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class HalLinkDiscoverer extends JsonPathLinkDiscoverer {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Link extractLink(Object element, LinkRelation rel) {
|
||||
|
||||
if (!Map.class.isInstance(element)) {
|
||||
if (!(element instanceof Map)) {
|
||||
return super.extractLink(element, rel);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ public class HalLinkRelation implements LinkRelation, MessageSourceResolvable {
|
||||
|
||||
Assert.notNull(relation, "LinkRelation must not be null!");
|
||||
|
||||
if (HalLinkRelation.class.isInstance(relation)) {
|
||||
return HalLinkRelation.class.cast(relation);
|
||||
if (relation instanceof HalLinkRelation) {
|
||||
return (HalLinkRelation) relation;
|
||||
}
|
||||
|
||||
return of(relation.value());
|
||||
|
||||
@@ -431,12 +431,12 @@ public class Jackson2HalModule extends SimpleModule {
|
||||
|
||||
Object firstElement = list.get(0);
|
||||
|
||||
if (!HalLink.class.isInstance(firstElement)) {
|
||||
if (!(firstElement instanceof HalLink)) {
|
||||
serializeContents(list, jgen, provider);
|
||||
return;
|
||||
}
|
||||
|
||||
HalLink halLink = HalLink.class.cast(firstElement);
|
||||
HalLink halLink = (HalLink) firstElement;
|
||||
|
||||
if (list.size() == 1 && halConfiguration.getSingleLinkRenderModeFor(halLink.getLink().getRel())
|
||||
.equals(RenderSingleLinks.AS_SINGLE)) {
|
||||
|
||||
@@ -150,7 +150,7 @@ class UberData {
|
||||
/**
|
||||
* Simple scalar types that can be encoded by value, not type.
|
||||
*/
|
||||
private final static HashSet<Class<?>> PRIMITIVE_TYPES = new HashSet<>(Arrays.asList(String.class));
|
||||
private final static HashSet<Class<?>> PRIMITIVE_TYPES = new HashSet<>(Collections.singletonList(String.class));
|
||||
|
||||
/**
|
||||
* Set of all Spring HATEOAS resource types.
|
||||
|
||||
@@ -38,7 +38,7 @@ public class UriTemplateFactory {
|
||||
* @param mapping must not be {@literal null} or empty.
|
||||
* @return
|
||||
*/
|
||||
public static UriTemplate templateFor(@Nullable String mapping) {
|
||||
public static UriTemplate templateFor(String mapping) {
|
||||
|
||||
Assert.hasText(mapping, "Mapping must not be null or empty!");
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public class RepresentationModelProcessorInvoker {
|
||||
}
|
||||
}
|
||||
|
||||
return (T) invokeProcessorsFor(Object.class.cast(value), referenceType);
|
||||
return (T) invokeProcessorsFor((Object) value, referenceType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user