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

io.github.danielnaczo.python3parser.model.stmts.Body Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package io.github.danielnaczo.python3parser.model.stmts;

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

import io.github.danielnaczo.python3parser.visitors.basic.Python3ASTVisitor;

//class is used for "suite" because it could have multiple statements

//e.g.:

// body.element1
// body.element2
// .......
public class Body extends Statement {

	List statements;
	Statement parentStmt;
	
	public Body() {
		this.statements = new ArrayList<>();
	}

	public Body(List statements) {
		this.statements = statements;
	}

	public List getStatements() {
		return statements;
	}

	public void setStatements(List statements) {
		this.statements = statements;
	}
	
	public Statement getParentStmt() {
		return parentStmt;
	}
	
	public void setParentStmt(Statement parentStmt) {
		this.parentStmt = parentStmt;
	}
	
	public void addStatement(Statement statement) {
		this.statements.add(statement);
		
	}
	
	public  R accept(Python3ASTVisitor visitor, P param) {
		return visitor.visitBody(this, param);
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		Body body = (Body) o;
		return Objects.equals(statements, body.statements);
	}

	@Override
	public int hashCode() {
		return Objects.hash(statements);
	}
	
	@Override
	public String toString() {
		return "Body";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy