All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.intelie.pipes.ast.RawNode Maven / Gradle / Ivy

There is a newer version: 0.25.5
Show newest version
package net.intelie.pipes.ast;

import net.intelie.pipes.util.Preconditions;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class RawNode implements AstNode {
    private static final long serialVersionUID = 1L;

    private final SourceLocation location;
    private final Object value;
    private final int _hash;

    public RawNode(SourceLocation location, Object value) {
        this.location = location;
        this.value = value;
        this._hash = Objects.hash(this.value);
    }

    public static List fromArray(Object... args) {
        List nodes = new ArrayList<>();
        for (Object o : args) {
            nodes.add(new RawNode(null, o));
        }
        return nodes;
    }

    public Object getValue() {
        return value;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }

    @Override
    public SourceLocation getLocation() {
        return location;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RawNode that = (RawNode) o;

        return Objects.equals(this.value, that.value);
    }

    @Override
    public int hashCode() {
        return _hash;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy