streams-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robdouglas <...@git.apache.org>
Subject [GitHub] incubator-streams pull request: Streams 68,218
Date Mon, 17 Nov 2014 19:06:02 GMT
Github user robdouglas commented on a diff in the pull request:

    https://github.com/apache/incubator-streams/pull/131#discussion_r20456206
  
    --- Diff: streams-components/streams-converters/src/main/java/org/apache/streams/converter/BaseDocumentClassifier.java
---
    @@ -0,0 +1,66 @@
    +package org.apache.streams.converter;
    +
    +import com.fasterxml.jackson.databind.ObjectMapper;
    +import com.fasterxml.jackson.databind.node.ObjectNode;
    +import com.google.common.base.Preconditions;
    +import org.apache.streams.data.DocumentClassifier;
    +import org.apache.streams.data.util.ActivityUtil;
    +import org.apache.streams.jackson.StreamsJacksonMapper;
    +import org.apache.streams.pojo.json.Activity;
    +
    +import java.io.IOException;
    +
    +/**
    + * BaseDocumentClassifier is included by default in all
    + * @see {@link org.apache.streams.converter.ActivityConverterProcessor}
    + *
    + * Ensures generic String and ObjectNode documents can be converted to Activity
    + *
    + */
    +public class BaseDocumentClassifier implements DocumentClassifier {
    +
    +    private static BaseDocumentClassifier instance = new BaseDocumentClassifier();
    +
    +    public static BaseDocumentClassifier getInstance() {
    +        return instance;
    +    }
    +
    +    private ObjectMapper mapper = StreamsJacksonMapper.getInstance();
    +
    +    @Override
    +    public Class detectClass(Object document) {
    +        Preconditions.checkArgument(
    --- End diff --
    
    Instead of failing a precondition, would it be better to log the issue and return null?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message