Interface ChordLeadSheetItem<T>
- Type Parameters:
T-
- All Superinterfaces:
Comparable<ChordLeadSheetItem<?>>, Transferable
- All Known Subinterfaces:
CLI_BarAnnotation, CLI_ChordSymbol, CLI_LoopRestartBar, CLI_Section, WritableItem<T>
- All Known Implementing Classes:
ChordLeadSheetItem.DefaultComparableItem, CLI_ChordSymbol.ComparableCsItem
This is a mutable class. Subclasses must define equals() and hashCode() to be compatible with compareTo(). 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().
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidintcompareToSamePosition(ChordLeadSheetItem<?> other) Compare this ChordLeadSheetItem with another ChordLeadSheetItem having the same position and same positionOrder.default intcompareToThreadUnsafe(ChordLeadSheetItem<?> other) A compareTo() thread-unsafe implementation which is consistent withequalsThreadUnsafe(org.jjazz.chordleadsheet.api.item.ChordLeadSheetItem, java.lang.Object).createItemFrom(int bar) Create an item at the beginning of the specified bar for comparison purposes.createItemFrom(Position pos, boolean inclusive) Create an item right before the specified position for comparison purposes.createItemTo(int bar) Create an item at the end of the specified bar for comparison purposes.createItemTo(Position pos, boolean inclusive) Create an item right after the specified position for comparison purposes.static booleanequalsThreadUnsafe(ChordLeadSheetItem<?> item, Object o) A thread-unsafe equals() helper implementation consistent withcompareToThreadUnsafe(org.jjazz.chordleadsheet.api.item.ChordLeadSheetItem).Get the client properties.Get the ChordLeadSheet this object belongs to.Get a copy of this item using the specified parameters.getData()Get the data part of this item.Get a copy of the position of this item.intA unique constant value used to order items which have the same position.static PropertyChangeEventgetVoidEvent(ChordLeadSheetItem<?> item) Return a PropertyChangeEvent which will not be fired.static inthashCodeThreadUnsafe(ChordLeadSheetItem<?> item) A thread-unsafe hashCode() helper implementation consistent withequalsThreadUnsafe(org.jjazz.chordleadsheet.api.item.ChordLeadSheetItem, java.lang.Object).booleanReturn true if there can be only one single item perbar, like a time signature.voidMethods inherited from interface Comparable
compareToMethods inherited from interface Transferable
getTransferData, getTransferDataFlavors, isDataFlavorSupported
-
Field Details
-
PROP_ITEM_DATA
-
PROP_ITEM_POSITION
-
-
Method Details
-
getContainer
-
getData
-
getPosition
-
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
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
-
compareToSamePosition
Compare this ChordLeadSheetItem with another ChordLeadSheetItem having the same position and same positionOrder.This method should be used by ChordLeadSheetItem.compareTo() when the 2 items meet the following criteria:
- this.equals(other)==false
- same position
- same positionOrder
- Parameters:
other-- Returns:
- See Also:
-
addPropertyChangeListener
-
removePropertyChangeListener
-
compareToThreadUnsafe
A compareTo() thread-unsafe implementation which is consistent withequalsThreadUnsafe(org.jjazz.chordleadsheet.api.item.ChordLeadSheetItem, java.lang.Object).Container and clientProperties are ignored. Relies on
.invalid @link
{@link #compareToSamePosition(org.jjazz.chordleadsheet.api.item.ChordLeadSheetItem).If thread-safety is required, subclass compareTo() implementation should call this method under a read lock.
- Parameters:
other-- Returns:
-
equalsThreadUnsafe
A thread-unsafe equals() helper implementation consistent withcompareToThreadUnsafe(org.jjazz.chordleadsheet.api.item.ChordLeadSheetItem).Container and clientProperties are ignored.
If thread-safety is required, subclass equals() implementation should call this method under a read lock.
- Parameters:
item- Cannot be nullo-- Returns:
-
hashCodeThreadUnsafe
A thread-unsafe hashCode() helper implementation consistent withequalsThreadUnsafe(org.jjazz.chordleadsheet.api.item.ChordLeadSheetItem, java.lang.Object).Container and clientProperties are ignored.
If thread-safety is required, subclass equals() implementation should call this method under a read lock.
- Parameters:
item-- Returns:
-
createItemTo
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
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
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
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:
-
getVoidEvent
Return a PropertyChangeEvent which will not be fired.- Parameters:
item-- Returns:
-