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.19 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.19-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.18 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.18-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.17 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.17-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.16 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.16-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.15 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.15-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.14 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.14-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.13 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.13-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.12 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.12-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.11-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.11 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.10 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.10-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java