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
Minor code cleanup #826
Minor code cleanup #826
Conversation
|
||
/** | ||
* Get a new TransformationFactory with the default classes | ||
* @throws SecurityException if security exception occurred | ||
*/ | ||
public TransformationFactory() { | ||
mimeToTransform.put(contentTypeSPARQLQuery, new SparqlQueryTransform(null)); | ||
mimeToTransform.put(APPLICATION_RDF_LDPATH, new LDPathTransform(null)); | ||
mimeToTransform.put(contentTypeSPARQLQuery, is -> new SparqlQueryTransform(is)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as in earlier PR:
mimeToTransform.put(contentTypeSPARQLQuery, SparqlQueryTransform::new);
@@ -56,7 +59,7 @@ public TransformationFactory() { | |||
public <T> Transformation<T> getTransform(final MediaType contentType, final InputStream inputStream) { | |||
final String mimeType = contentType.toString(); | |||
if (mimeToTransform.containsKey(mimeType)) { | |||
return (Transformation<T>) mimeToTransform.get(contentType.toString()).newTransform(inputStream); | |||
return mimeToTransform.get(contentType.toString()).apply(inputStream); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems incorrect to me. The previous logic returned a new transformation with the arg inputStream
query. The new logic returns a new transformation trying to apply the arg inputStream
as if it were an RdfStream
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it doesn't. The tests wouldn't even pass if it did that. RdfStream
has no relevance here. Look at the new type of mimeToTransform
: Map<String, Function<InputStream, Transformation>>
. Give it a String
, it will give you a Function<InputStream, Transformation>
. The old type let you give it a String
and gave you a Transform
which was only used to produce a new Transform
via newTransform(InputStream)
(which no longer exists). newTransform(InputStream)
was semantically equivalent to Function<InputStream, Transformation>
, but the new way is not idiosyncratic. The semantics are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was perplexing me is the fact that Transformation
has an apply(RdfStream)
method that overrides Function::apply
. However, there is another lambda function at play that has its own apply
method.
I see the layers now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's currying. The whole type is: String
-> InputStream
-> RdfStream
-> Something
(whatever the Transformation
goes to).
Resolved with: 1a4cf67 |
https://jira.duraspace.org/browse/FCREPO-1606