content: /*
   * Copyright 2021-2022 Alibaba Group Holding Ltd.
   *
   *    Licensed under the Apache License, Version 2.0 (the "License");
   *    you may not use this file except in compliance with the License.
   *    You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *    Unless required by applicable law or agreed to in writing, software
   *    distributed under the License is distributed on an "AS IS" BASIS,
   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *    See the License for the specific language governing permissions and
   *    limitations under the License.
   */
  
  package com.aliyun.fastmodel.core.tree.datatype;
  
  import java.util.List;
  import java.util.Objects;
  
  import com.aliyun.fastmodel.core.tree.IAstVisitor;
  import com.aliyun.fastmodel.core.tree.Node;
  import com.aliyun.fastmodel.core.tree.NodeLocation;
  import lombok.Getter;
  import org.apache.commons.lang3.StringUtils;
  
  /**
   * RowDataType : 一行的类型
   *
   * @author panguanjing
   * @date 2020/10/30
   */
  @Getter
  public class RowDataType extends BaseDataType {
  
      private final List<Field> fields;
  
      public RowDataType(NodeLocation location, String origin,
                         List<Field> fields) {
          super(location, origin);
          this.fields = fields;
      }
  
      public RowDataType(List<Field> fields) {
          this(null, null, fields);
      }
  
      @Override
      public <R, C> R accept(IAstVisitor<R, C> visitor, C context) {
          return visitor.visitRowDataType(this, context);
      }
  
      @Override
      public List<? extends Node> getChildren() {
          return fields;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) {return true;}
          if (o == null || getClass() != o.getClass()) {return false;}
          RowDataType rowDataType = (RowDataType)o;
          boolean e = StringUtils.equalsIgnoreCase(this.getTypeName().getValue(), rowDataType.getTypeName().getValue());
          if (!e) {
              return false;
          }
          return Objects.equals(fields, rowDataType.getFields());
      }
  
      @Override
      public IDataTypeName getTypeName() {
          return DataTypeEnums.STRUCT;
      }
  }
  