Note.java

  1. /*
  2.  * Copyright (C) 2010, 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.notes;

  11. import org.eclipse.jgit.lib.AnyObjectId;
  12. import org.eclipse.jgit.lib.ObjectId;

  13. /**
  14.  * In-memory representation of a single note attached to one object.
  15.  */
  16. public class Note extends ObjectId {
  17.     private ObjectId data;

  18.     /**
  19.      * A Git note about the object referenced by {@code noteOn}.
  20.      *
  21.      * @param noteOn
  22.      *            the object that has a note attached to it.
  23.      * @param noteData
  24.      *            the actual note data contained in this note
  25.      */
  26.     public Note(AnyObjectId noteOn, ObjectId noteData) {
  27.         super(noteOn);
  28.         data = noteData;
  29.     }

  30.     /**
  31.      * Get the note content.
  32.      *
  33.      * @return the note content.
  34.      */
  35.     public ObjectId getData() {
  36.         return data;
  37.     }

  38.     void setData(ObjectId newData) {
  39.         data = newData;
  40.     }

  41.     /** {@inheritDoc} */
  42.     @SuppressWarnings("nls")
  43.     @Override
  44.     public String toString() {
  45.         return "Note[" + name() + " -> " + data.name() + "]";
  46.     }
  47. }