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

io.github.danielnaczo.python3parser.model.stmts.flowStmts.Raise Maven / Gradle / Ivy

The newest version!
package io.github.danielnaczo.python3parser.model.stmts.flowStmts;

import java.util.Objects;
import java.util.Optional;

import io.github.danielnaczo.python3parser.model.expr.Expression;
import io.github.danielnaczo.python3parser.model.stmts.Statement;
import io.github.danielnaczo.python3parser.visitors.basic.Python3ASTVisitor;

// e.g.:

// raise exc from cause
public class Raise extends Statement{

	Optional exc;
	Optional cause;
	
	public Raise() {
		this(null, null);
	}
	
	public Raise(Expression exc) {
		this(exc, null);
	}
	
	public Raise(Expression exc, Expression cause) {
		this.exc = Optional.ofNullable(exc);
		this.cause = Optional.ofNullable(cause);
	}

	public Optional getExc() {
		return exc;
	}

	public void setExc(Optional exc) {
		this.exc = exc;
	}

	public Optional getCause() {
		return cause;
	}

	public void setCause(Optional cause) {
		this.cause = cause;
	}
	
	public  R accept(Python3ASTVisitor visitor, P param) {
		return visitor.visitRaise(this, param);
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		Raise raise = (Raise) o;
		return Objects.equals(exc, raise.exc) &&
				Objects.equals(cause, raise.cause);
	}

	@Override
	public int hashCode() {
		return Objects.hash(exc, cause);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy