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.29 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.29-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.28 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.28-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.27 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.27-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.26 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.26-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.25 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.25-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.24 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.24-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.23 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.23-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.22 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.22-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.21 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.21-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.20 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.20-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java