/* Inductive -- Automatically generated by TreeBuilder (2024-10-27T16:47Z) */ package de.uni_freiburg.informatik.ultimate.model.acsl.ast; import java.util.List; import java.util.Arrays; import java.util.ArrayList; import de.uni_freiburg.informatik.ultimate.model.acsl.ACSLNode; /** * Represents a inductive which is a special form of a logic statement. */ public class Inductive extends LogicStatement { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(Inductive.class); /** * The cases of this inductive. */ Case[] cases; /** * The constructor taking initial values. * @param polyId the poly id of this logic statement. * @param cases the cases of this inductive. */ public Inductive(PolyIdentifier polyId, Case[] cases) { super(polyId); this.cases = cases; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid Inductive: " + this; } /** * The constructor taking initial values. * @param polyId the poly id of this logic statement. * @param parameters the parameters of this logic statement. * @param cases the cases of this inductive. */ public Inductive(PolyIdentifier polyId, Parameter[] parameters, Case[] cases) { super(polyId, parameters); this.cases = cases; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid Inductive: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Inductive").append('['); if (cases == null) { sb.append("null"); } else { sb.append('['); for(int i1 = 0; i1 < cases.length; i1++) { if (i1 > 0) sb.append(','); sb.append(cases[i1]); } sb.append(']'); } return sb.append(']').toString(); } /** * Gets the cases of this inductive. * @return the cases of this inductive. */ public Case[] getCases() { return cases; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); if(cases!=null){ children.addAll(Arrays.asList(cases)); } return children; } public void accept(ACSLVisitor visitor) { if (visitor.visit((LogicStatement)this)) { //visit parent types higher up if necessary } else { return; } if (visitor.visit(this)) { if(cases!=null){ for (Case elem : cases) { elem.accept(visitor); } } if(polyId!=null){ polyId.accept(visitor); } if(parameters!=null){ for (Parameter elem : parameters) { elem.accept(visitor); } } } } public LogicStatement accept(ACSLTransformer visitor) { LogicStatement node = visitor.transform(this); if(node != this){ return node; } boolean isChanged=false; ArrayList tmpListnewcases = new ArrayList<>(); if(cases != null){ for(Case elem : cases){ Case newcases = (Case)elem.accept(visitor); isChanged = isChanged || newcases != elem; tmpListnewcases.add(newcases); } } PolyIdentifier newpolyId = null; if(polyId != null){ newpolyId = (PolyIdentifier)polyId.accept(visitor); } ArrayList tmpListnewparameters = new ArrayList<>(); if(parameters != null){ for(Parameter elem : parameters){ Parameter newparameters = (Parameter)elem.accept(visitor); isChanged = isChanged || newparameters != elem; tmpListnewparameters.add(newparameters); } } if(isChanged || polyId != newpolyId){ return new Inductive(newpolyId, tmpListnewparameters.toArray(new Parameter[0]), tmpListnewcases.toArray(new Case[0])); } return this; } }