EditList.java

  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. package org.eclipse.jgit.diff;

  11. import java.util.ArrayList;

  12. /**
  13.  * Specialized list of {@link org.eclipse.jgit.diff.Edit}s in a document.
  14.  */
  15. public class EditList extends ArrayList<Edit> {
  16.     private static final long serialVersionUID = 1L;

  17.     /**
  18.      * Construct an edit list containing a single edit.
  19.      *
  20.      * @param edit
  21.      *            the edit to return in the list.
  22.      * @return list containing only {@code edit}.
  23.      */
  24.     public static EditList singleton(Edit edit) {
  25.         EditList res = new EditList(1);
  26.         res.add(edit);
  27.         return res;
  28.     }

  29.     /**
  30.      * Create a new, empty edit list.
  31.      */
  32.     public EditList() {
  33.         super(16);
  34.     }

  35.     /**
  36.      * Create an empty edit list with the specified capacity.
  37.      *
  38.      * @param capacity
  39.      *            the initial capacity of the edit list. If additional edits are
  40.      *            added to the list, it will be grown to support them.
  41.      */
  42.     public EditList(int capacity) {
  43.         super(capacity);
  44.     }

  45.     /** {@inheritDoc} */
  46.     @Override
  47.     public String toString() {
  48.         return "EditList" + super.toString(); //$NON-NLS-1$
  49.     }
  50. }