From e4b63a5b51acab70540f1c36401d22a6f2d76d45 Mon Sep 17 00:00:00 2001 From: alexVengrovsk Date: Thu, 8 Oct 2015 12:01:44 +0300 Subject: [PATCH] Use instanceof for better readability --- .../cloud/netflix/feign/support/SpringMvcContract.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringMvcContract.java b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringMvcContract.java index e684a87c..c7253c40 100644 --- a/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringMvcContract.java +++ b/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringMvcContract.java @@ -128,9 +128,7 @@ public class SpringMvcContract extends Contract.BaseContract { boolean isHttpAnnotation = false; // TODO: support spring parameter annotations? for (Annotation parameterAnnotation : annotations) { - Class annotationType = parameterAnnotation - .annotationType(); - if (annotationType == PathVariable.class) { + if (parameterAnnotation instanceof PathVariable) { String name = PathVariable.class.cast(parameterAnnotation).value(); checkState(emptyToNull(name) != null, "PathVariable annotation was empty on param %s.", paramIndex); @@ -143,7 +141,7 @@ public class SpringMvcContract extends Contract.BaseContract { data.formParams().add(name); } } - else if (annotationType == RequestParam.class) { + else if (parameterAnnotation instanceof RequestParam) { String name = RequestParam.class.cast(parameterAnnotation).value(); checkState(emptyToNull(name) != null, "QueryParam.value() was empty on parameter %s", paramIndex); @@ -153,7 +151,7 @@ public class SpringMvcContract extends Contract.BaseContract { nameParam(data, name, paramIndex); isHttpAnnotation = true; } - else if (annotationType == RequestHeader.class) { + else if (parameterAnnotation instanceof RequestHeader) { String name = RequestHeader.class.cast(parameterAnnotation).value(); checkState(emptyToNull(name) != null, "HeaderParam.value() was empty on parameter %s", paramIndex);