package cn.palmte.work.model.process;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.persistence.Convert;

import cn.palmte.work.model.enums.Enumerable;
import cn.palmte.work.model.enums.SealType;

/**
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
 * @since 2.0 2022/12/14 16:35
 */
//@JsonSerialize
@Convert(converter = SealTypeArrayConverter.class)
public class SealTypeArray {
  public static final SealTypeArray EMPTY = new SealTypeArray();

  private final List<SealType> sealTypes = new ArrayList<>();

  public SealTypeArray() { }

  public SealTypeArray(SealType... sealTypes) {
    Collections.addAll(this.sealTypes, sealTypes);
  }

  public List<SealType> getSealTypes() {
    return sealTypes;
  }

  public void setSealTypes(List<SealType> sealTypes) {
    this.sealTypes.clear();
    this.sealTypes.addAll(sealTypes);
  }

  //

  public static SealTypeArray of(SealType... sealTypes) {
    return new SealTypeArray(sealTypes);
  }

  public static SealTypeArray of(String... sealTypes) {
    return of(Arrays.stream(sealTypes)
            .map(type -> Enumerable.of(SealType.class, type))
            .toArray(SealType[]::new));
  }

  public static SealTypeArray of(Collection<SealType> sealTypes) {
    SealTypeArray sealTypeArray = new SealTypeArray();
    sealTypeArray.sealTypes.addAll(sealTypes);
    return sealTypeArray;
  }

}
