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.39 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.39-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.38 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.38-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.37 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.37-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.36 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.36-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.35 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.35-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.34 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.34-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.33 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.33-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.32 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.32-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.31 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.31-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.30 embulk-core/src/main/java/org/embulk/spi/unit/ToString.java
embulk-0.8.30-java embulk-core/src/main/java/org/embulk/spi/unit/ToString.java