Interface ChordLeadSheetItem<T>

Type Parameters:
T -
All Superinterfaces:
Comparable<ChordLeadSheetItem<?>>, Transferable
All Known Subinterfaces:
CLI_BarAnnotation, CLI_ChordSymbol, CLI_Section, WritableItem<T>
All Known Implementing Classes:
ChordLeadSheetItem.DefaultComparableItem, CLI_ChordSymbol.ComparableCsItem

public interface ChordLeadSheetItem<T> extends Transferable, Comparable<ChordLeadSheetItem<?>>
Items which belong to a ChordLeadSheet.

PropertyChangeEvents are fired when an attribute is modified.

This is a mutable class and subclasses should define equals() and hashCode(): if you want to use ChordLeadSheetItems as Map keys you should use an IdentityHashMap, unless you are sure ChordLeadSheetItems won't mutate. Same for a Set, you should use Guava Sets.newIdentityHashSet().

  • Field Details

  • Method Details

    • getContainer

      ChordLeadSheet getContainer()
      Get the ChordLeadSheet this object belongs to.
      Returns:
      Can be null.
    • getData

      T getData()
      Get the data part of this item.
      Returns:
    • getPosition

      Position getPosition()
      Get a copy of the position of this item.
      Returns:
    • getPositionOrder

      int getPositionOrder()
      A unique constant value used to order items which have the same position.

      Returns:
      Must be a unique value for each type of item
      See Also:
    • getCopy

      ChordLeadSheetItem<T> getCopy(T newData, Position newPos)
      Get a copy of this item using the specified parameters.

      Client properties are also copied. Returned copy has its ChordLeadSheet container set to null.

      Parameters:
      newData - If null, the copy will have the same data than this object.
      newPos - If null, the copy will have the same position than this object.
      Returns:
    • isBarSingleItem

      boolean isBarSingleItem()
      Return true if there can be only one single item perbar, like a time signature.

      Returns:
    • getClientProperties

      StringProperties getClientProperties()
      Get the client properties.
      Returns:
    • compareTo

      default int compareTo(ChordLeadSheetItem<?> other)
      Default implementation compares items only using position then positionOrder if required.

      Specified by:
      compareTo in interface Comparable<T>
      Parameters:
      other -
      Returns:
      0 only if this.equals(other), so that comparison is consistent with equals().
      See Also:
    • addPropertyChangeListener

      void addPropertyChangeListener(PropertyChangeListener listener)
    • removePropertyChangeListener

      void removePropertyChangeListener(PropertyChangeListener listener)
    • equals

      static boolean equals(ChordLeadSheetItem<?> item1, Object o)
      Generic equals method relying only on data and position.

      Parameters:
      item1 - Can not be null
      o -
      Returns:
    • hashCode

      static int hashCode(ChordLeadSheetItem<?> item)
      Generic hashCode method relying on data and position.
      Parameters:
      item -
      Returns:
    • createItemTo

      static ChordLeadSheetItem.DefaultComparableItem createItemTo(Position pos, boolean inclusive)
      Create an item right after the specified position for comparison purposes.

      For the Comparable interface, any item whose position is before (or equal if inclusive is true) to pos will be considered BEFORE the returned item.

      Parameters:
      pos -
      inclusive -
      Returns:
    • createItemTo

      static ChordLeadSheetItem.DefaultComparableItem createItemTo(int bar)
      Create an item at the end of the specified bar for comparison purposes.

      For the Comparable interface, any normal item in the bar will be considered BEFORE the returned item.

      Parameters:
      bar -
      Returns:
    • createItemFrom

      static ChordLeadSheetItem.DefaultComparableItem createItemFrom(Position pos, boolean inclusive)
      Create an item right before the specified position for comparison purposes.

      For the Comparable interface, any item whose position is after (or equal if inclusive is true) to pos will be considered AFTER the returned item.

      Parameters:
      pos -
      inclusive -
      Returns:
    • createItemFrom

      static ChordLeadSheetItem.DefaultComparableItem createItemFrom(int bar)
      Create an item at the beginning of the specified bar for comparison purposes.

      For the Comparable interface, any normal item in the bar will be considered AFTER the returned item.

      Parameters:
      bar -
      Returns: