View Javadoc
1   /*
2    * Copyright (C) 2009, Google Inc. and others
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  
11  package org.eclipse.jgit.diff;
12  
13  import java.util.ArrayList;
14  
15  /**
16   * Specialized list of {@link org.eclipse.jgit.diff.Edit}s in a document.
17   */
18  public class EditList extends ArrayList<Edit> {
19  	private static final long serialVersionUID = 1L;
20  
21  	/**
22  	 * Construct an edit list containing a single edit.
23  	 *
24  	 * @param edit
25  	 *            the edit to return in the list.
26  	 * @return list containing only {@code edit}.
27  	 */
28  	public static EditList singleton(Edit edit) {
29  		EditList res = new EditList(1);
30  		res.add(edit);
31  		return res;
32  	}
33  
34  	/**
35  	 * Create a new, empty edit list.
36  	 */
37  	public EditList() {
38  		super(16);
39  	}
40  
41  	/**
42  	 * Create an empty edit list with the specified capacity.
43  	 *
44  	 * @param capacity
45  	 *            the initial capacity of the edit list. If additional edits are
46  	 *            added to the list, it will be grown to support them.
47  	 */
48  	public EditList(int capacity) {
49  		super(capacity);
50  	}
51  
52  	/** {@inheritDoc} */
53  	@Override
54  	public String toString() {
55  		return "EditList" + super.toString(); //$NON-NLS-1$
56  	}
57  }