hydra.langs.tinkerpop.mappings.ValueSpec Maven / Gradle / Ivy
package hydra.langs.tinkerpop.mappings;
import java.io.Serializable;
/**
* A mapping specification producing values (usually literal values) whose type is understood in context
*/
public abstract class ValueSpec implements Serializable {
public static final hydra.core.Name NAME = new hydra.core.Name("hydra/langs/tinkerpop/mappings.ValueSpec");
private ValueSpec () {
}
public abstract R accept(Visitor visitor) ;
public interface Visitor {
R visit(Value instance) ;
R visit(Pattern instance) ;
}
public interface PartialVisitor extends Visitor {
default R otherwise(ValueSpec instance) {
throw new IllegalStateException("Non-exhaustive patterns when matching: " + (instance));
}
default R visit(Value instance) {
return otherwise((instance));
}
default R visit(Pattern instance) {
return otherwise((instance));
}
}
/**
* A trivial no-op specification which passes the entire value
*/
public static final class Value extends hydra.langs.tinkerpop.mappings.ValueSpec implements Serializable {
public Value () {
}
@Override
public boolean equals(Object other) {
if (!(other instanceof Value)) {
return false;
}
Value o = (Value) (other);
return true;
}
@Override
public int hashCode() {
return 0;
}
@Override
public R accept(Visitor visitor) {
return visitor.visit(this);
}
}
/**
* A compact path representing the function, e.g. engine-${engineInfo/model/name}
*/
public static final class Pattern extends hydra.langs.tinkerpop.mappings.ValueSpec implements Serializable {
/**
* A compact path representing the function, e.g. engine-${engineInfo/model/name}
*/
public final String value;
public Pattern (String value) {
this.value = value;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof Pattern)) {
return false;
}
Pattern o = (Pattern) (other);
return value.equals(o.value);
}
@Override
public int hashCode() {
return 2 * value.hashCode();
}
@Override
public R accept(Visitor visitor) {
return visitor.visit(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy