Sha256: 8d840b3da60dca59dfd4ade91dd8731c52027769b6a11ccc52fa31c435ef49b7

Contents?: true

Size: 1.3 KB

Versions: 113

Compression:

Stored size: 1.3 KB

Contents

package org.embulk.spi.unit;

import com.google.common.base.Optional;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.node.NullNode;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public class ToString
{
    private final String string;

    public ToString(String string)
    {
        this.string = string;
    }

    @JsonCreator
    public ToString(Optional<JsonNode> option) throws JsonMappingException
    {
        JsonNode node = option.or(NullNode.getInstance());
        if (node.isTextual()) {
            this.string = node.textValue();
        } else if (node.isValueNode()) {
            this.string = node.toString();
        } else {
            throw new JsonMappingException(String.format("Arrays and objects are invalid: '%s'", node));
        }
    }

    @Override
    public boolean equals(Object obj)
    {
        if (!(obj instanceof ToString)) {
            return false;
        }
        ToString o = (ToString) obj;
        return string.equals(o.string);
    }

    @Override
    public int hashCode()
    {
        return string.hashCode();
    }

    @JsonValue
    @Override
    public String toString()
    {
        return string;
    }
}

Version data entries

113 entries across 113 versions & 1 rubygems

Version Path
embulk-0.8.9 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.9-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.8 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.8-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.7 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.7-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.6 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.6-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.5 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.5-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.4 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.4-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.3 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.3-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.7.11 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.7.11-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.2 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.2-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.1 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.1-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java