Class ChordBuilder

java.lang.Object
org.wmn4j.notation.ChordBuilder
All Implemented Interfaces:
Iterable<NoteBuilder>, DurationalBuilder

public final class ChordBuilder extends Object implements DurationalBuilder, Iterable<NoteBuilder>
Class for building Chord objects.

Instances of this class are not thread-safe.

  • Constructor Details

    • ChordBuilder

      public ChordBuilder(NoteBuilder noteBuilder)
      Constructor. This builder takes ownership of the given NoteBuilder.
      Parameters:
      noteBuilder - the note builder that specifies the first note in this builder
    • ChordBuilder

      public ChordBuilder(List<NoteBuilder> noteBuilders)
      Constructor. This builder takes ownership of the given NoteBuilders.
      Parameters:
      noteBuilders - the note builders that are placed into this builder
    • ChordBuilder

      public ChordBuilder(Chord chord)
      Constructor that creates a new builder with the contents of the given chord. Ties and connected notations in the notes of the given chord are not copied.
      Parameters:
      chord - the chord from which the contents of notes are copied to this builder
  • Method Details

    • add

      public ChordBuilder add(NoteBuilder noteBuilder)
      Adds the given NoteBuilder into this builder. This builder takes ownership of the given NoteBuilder.
      Parameters:
      noteBuilder - the note builder that is added to this builder
      Returns:
      reference to this
    • removeIf

      public ChordBuilder removeIf(Predicate<NoteBuilder> filter)
      Remove a NoteBuilder placed in this ChordBuilder.
      Parameters:
      filter - Predicate to determine which NoteBuilders are removed
      Returns:
      reference to this
    • isChordBuilder

      public boolean isChordBuilder()
      Description copied from interface: DurationalBuilder
      Returns true if this is a chord builder, false otherwise.
      Specified by:
      isChordBuilder in interface DurationalBuilder
      Returns:
      true if this is a chord builder, false otherwise
    • setDuration

      public ChordBuilder setDuration(Duration duration)
      Sets a new duration to this builder and all the NoteBuilders in it.
      Specified by:
      setDuration in interface DurationalBuilder
      Parameters:
      duration - Duration to set
      Returns:
      reference to this
    • getDuration

      public Duration getDuration()
      Description copied from interface: DurationalBuilder
      Returns the duration set in this builder.
      Specified by:
      getDuration in interface DurationalBuilder
      Returns:
      the duration set in this builder
    • iterator

      public Iterator<NoteBuilder> iterator()
      Specified by:
      iterator in interface Iterable<NoteBuilder>
    • build

      public Chord build()
      Description copied from interface: DurationalBuilder
      Returns a durational notation element with the values set in the builder.
      Specified by:
      build in interface DurationalBuilder
      Returns:
      a durational notation element with the values set in the builder