001/*
002 * Copyright (c) 2012-2017 Institut National des Sciences Appliquées de Lyon (INSA-Lyon)
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 */
009
010package org.eclipse.golo.compiler.parser;
011
012import java.util.List;
013import java.util.ArrayList;
014import static java.util.Collections.unmodifiableList;
015
016public class ASTDestructuringAssignment extends GoloASTNode {
017
018  private ASTLetOrVar.Type type;
019  private List<String> names = new ArrayList<>();
020  private boolean isVarargs = false;
021
022  public ASTDestructuringAssignment(int id) {
023    super(id);
024  }
025
026  public ASTDestructuringAssignment(GoloParser p, int id) {
027    super(p, id);
028  }
029
030  public ASTLetOrVar.Type getType() {
031    return type;
032  }
033
034  public void setType(ASTLetOrVar.Type type) {
035    this.type = type;
036  }
037
038  public List<String> getNames() {
039    return unmodifiableList(names);
040  }
041
042  public void setNames(List<String> names) {
043    this.names.clear();
044    this.names.addAll(names);
045  }
046
047  public void setVarargs(boolean b) {
048    this.isVarargs = b;
049  }
050
051  public boolean isVarargs() {
052    return this.isVarargs;
053  }
054
055  @Override
056  public String toString() {
057    return String.format("ASTDestructuringAssignment{type=%s, names=%s, varargs=%s}",
058           type, names, isVarargs);
059  }
060
061  @Override
062  public Object jjtAccept(GoloParserVisitor visitor, Object data) {
063    return visitor.visit(this, data);
064  }
065}