Represents a sequence of zero or more objects of a given type. The type can be omitted in which case any type of object can be added.
| 31 | * The type can be omitted in which case any type of object can be added. |
| 32 | */ |
| 33 | public class Sequence extends ArrayList implements GroovyObject { |
| 34 | |
| 35 | @Serial private static final long serialVersionUID = 5697409354934589471L; |
| 36 | private transient MetaClass metaClass = InvokerHelper.getMetaClass(getClass()); |
| 37 | private final Class type; |
| 38 | private int hashCode; |
| 39 | |
| 40 | /** |
| 41 | * Creates a sequence with no type restriction. |
| 42 | */ |
| 43 | public Sequence() { |
| 44 | this(null); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Creates a sequence constrained to the supplied type. |
| 49 | * |
| 50 | * @param type the allowed element type |
| 51 | */ |
| 52 | public Sequence(Class type) { |
| 53 | this.type = type; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Creates a sequence initialized with the supplied content. |
| 58 | * |
| 59 | * @param type the allowed element type |
| 60 | * @param content the initial content |
| 61 | */ |
| 62 | public Sequence(Class type, List content) { |
| 63 | super(content.size()); |
| 64 | this.type = type; |
| 65 | addAll(content); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Sets the contents of this sequence to that |
| 70 | * of the given collection. |
| 71 | */ |
| 72 | public void set(Collection collection) { |
| 73 | checkCollectionType(collection); |
| 74 | clear(); |
| 75 | addAll(collection); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * {@inheritDoc} |
| 80 | */ |
| 81 | @Override |
| 82 | public boolean equals(Object that) { |
| 83 | if (that instanceof Sequence) { |
| 84 | return equals((Sequence) that); |
| 85 | } |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Compares this sequence with another sequence using Groovy equality. |
nothing calls this directly
no test coverage detected
searching dependent graphs…