Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Minor code cleanup #826

wants to merge 2 commits into from

Conversation

ajs6f
Copy link
Contributor

@ajs6f ajs6f commented Jun 26, 2015


/**
* 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));
Copy link

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);
Copy link

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.

Copy link
Contributor Author

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.

Copy link

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.

Copy link
Contributor Author

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).

@awoods
Copy link

awoods commented Jun 30, 2015

Resolved with: 1a4cf67

@awoods awoods closed this Jun 30, 2015
@awoods awoods deleted the Java8StuffForTransform branch June 30, 2015 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants