Skip to content

Commit

Permalink
[APHL-1180] code Quality
Browse files Browse the repository at this point in the history
  • Loading branch information
taha.attari@smilecdr.com committed Dec 18, 2024
1 parent abeb51f commit dcab860
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,16 @@ public default <B extends IBase> List<B> resolvePathList(IBase base, String path
return resolvePathList(base, path).stream().map(i -> (B) i).collect(Collectors.toList());
}

@SuppressWarnings("unchecked")
public default String resolvePathString(IBase base, String path) {
var result = resolvePath(base, path);
if (result == null) {
return null;
} else if (result instanceof IPrimitiveType) {
return ((IPrimitiveType<String>) result).getValue();
} else if (result instanceof IBaseReference) {
return ((IBaseReference) result).getReferenceElement().getValue();
} else if (result instanceof IPrimitiveType primitive && primitive.getValue() instanceof String string) {
return string;
} else if (result instanceof IBaseReference reference) {
return reference.getReferenceElement().getValue();
} else {
throw new UnprocessableEntityException("Path : " + path + " on element of type "
+ base.getClass().getSimpleName() + "could not be resolved");
throw new UnprocessableEntityException("Path : {} on element of type {} could not be resolved", path, base.getClass().getSimpleName() );
}
}

Expand Down

0 comments on commit dcab860

Please sign in to comment.