Skip to content

Commit

Permalink
Merge pull request #56 from sashirestela/55-fix-residual-code-smells
Browse files Browse the repository at this point in the history
Fixing residual code smells
  • Loading branch information
sashirestela authored Mar 19, 2024
2 parents cf6a6e4 + 315817b commit c9d428d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.sashirestela</groupId>
<artifactId>cleverclient</artifactId>
<version>1.1.0</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>cleverclient</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.slf4j.LoggerFactory;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -79,12 +80,7 @@ private List<AnnotationMetadata> getAnnotations(Annotation[] javaAnnotations) {
for (var javaAnnotation : javaAnnotations) {
Map<String, String> valueByField = new HashMap<>();
for (var javaAnnotMethod : javaAnnotation.annotationType().getDeclaredMethods()) {
Object object;
try {
object = javaAnnotMethod.invoke(javaAnnotation, (Object[]) null);
} catch (Exception e) {
object = null;
}
Object object = getAnnotationValue(javaAnnotation, javaAnnotMethod);
if (object instanceof Annotation[]) {
isAnnotArray = true;
annotations.addAll(getAnnotations((Annotation[]) object));
Expand Down Expand Up @@ -142,4 +138,14 @@ private void validate(InterfaceMetadata interfaceMetadata) {
});
}

private Object getAnnotationValue(Annotation javaAnnotation, Method javaAnnotMethod) {
Object object;
try {
object = javaAnnotMethod.invoke(javaAnnotation, (Object[]) null);
} catch (Exception e) {
object = null;
}
return object;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public <S, T> Object sendRequest(HttpClient httpClient, HttpRequest httpRequest,
final var lineRecord = new CleverClientSSE.LineRecord();

return response.body()
.peek(line -> {
.map(line -> {
logger.debug("Response : {}", line);
lineRecord.updateWith(line);
return new CleverClientSSE(lineRecord);
})
.map(line -> new CleverClientSSE(lineRecord))
.filter(CleverClientSSE::isActualData)
.map(item -> JsonUtil.jsonToObject(item.getActualData(), responseClass));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public <S, T> Object sendRequest(HttpClient httpClient, HttpRequest httpRequest,
final var lineRecord = new CleverClientSSE.LineRecord();

return httpResponse.body()
.peek(line -> {
.map(line -> {
logger.debug("Response : {}", line);
lineRecord.updateWith(line);
return new CleverClientSSE(lineRecord);
})
.map(line -> new CleverClientSSE(lineRecord))
.filter(CleverClientSSE::isActualData)
.map(item -> JsonUtil.jsonToObject(item.getActualData(), responseClass));

Expand Down

0 comments on commit c9d428d

Please sign in to comment.