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

org.coode.oppl.generated.GeneratedVariable Maven / Gradle / Ivy

package org.coode.oppl.generated;

import static org.coode.oppl.utils.ArgCheck.checkNotNull;

import org.coode.oppl.ConstraintSystem;
import org.coode.oppl.ManchesterVariableSyntax;
import org.coode.oppl.Variable;
import org.coode.oppl.VariableVisitor;
import org.coode.oppl.VariableVisitorEx;
import org.coode.oppl.function.OPPLFunction;
import org.coode.oppl.variabletypes.VariableType;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLObject;

/** @author Luigi Iannone
 * @param 
 *            type */
public class GeneratedVariable implements Variable {
    private final OPPLFunction opplFunction;
    private final String name;
    private final IRI iri;
    private final VariableType type;

    protected GeneratedVariable(String name, VariableType type,
            OPPLFunction opplFunction) {
        this.name = checkNotNull(name, "name");
        this.type = checkNotNull(type, "type");
        this.opplFunction = checkNotNull(opplFunction, "opplFunction");
        this.iri = IRI.create(ManchesterVariableSyntax.NAMESPACE + this.getName());
    }

    @Override
    public String render(ConstraintSystem constraintSystem) {
        return String.format("%s:%s = %s", this.getName(), this.getType(), this
                .getOPPLFunction().render(constraintSystem));
    }

    @Override
    public String toString() {
        return String.format("%s:%s", this.getName(), this.getType());
    }

    /** @return the opplFunction */
    public OPPLFunction getOPPLFunction() {
        return this.opplFunction;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public IRI getIRI() {
        return this.iri;
    }

    @Override
    public VariableType getType() {
        return this.type;
    }

    @Override
    public void accept(VariableVisitor visitor) {
        visitor.visit(this);
    }

    @Override
    public  T accept(VariableVisitorEx visitor) {
        return visitor.visit(this);
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (this.name == null ? 0 : this.name.hashCode());
        result = prime * result + (this.type == null ? 0 : this.type.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (this.getClass() != obj.getClass()) {
            return false;
        }
        GeneratedVariable other = (GeneratedVariable) obj;
        if (this.name == null) {
            if (other.name != null) {
                return false;
            }
        } else if (!this.name.equals(other.name)) {
            return false;
        }
        if (this.type == null) {
            if (other.type != null) {
                return false;
            }
        } else if (!this.type.equals(other.type)) {
            return false;
        }
        return true;
    }

    /** @param name
     *            name
     * @param type
     *            type
     * @param opplFunction
     *            opplFunction
     * @param 

* variable type * @return generated variable */ public static

GeneratedVariable

getGeneratedVariable( String name, VariableType

type, OPPLFunction opplFunction) { return new GeneratedVariable

(name, type, opplFunction); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy