Package a.b.m2

Examples of a.b.m2.Section


  @Test
  public void createBeanCreateCloneThenCloneShouldHaveSameStructureAndValuesButEveryElementOfDifferentReference() {
   
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
   
    // instantiate cloner
    BookCloner987 bookCloner987 = new BookCloner987();
   
    // create clone
    Book clonedBook = bookCloner987.apply(book);
   
    // check assumptions
    assertNotNull(clonedBook);
   
    // clone should have same structure and values
    assertEquals(clonedBook.getAuthor(), "John O'Farrel");
    assertEquals(clonedBook.getSections().get(1).getName(), "Section2");
    assertEquals(clonedBook.getSections().get(1).getParagraphs().iterator().next().getNumber(), new Integer(1066));
       
    // ..but every element of different reference
    assertFalse(clonedBook == book);
    assertFalse(clonedBook.getSections().get(1) == book.getSections().get(1));
    assertFalse(clonedBook.getSections().get(1).getParagraphs().iterator().next() == book.getSections().get(1).getParagraphs().iterator().next());
  }
View Full Code Here


public class SimpleApp {
  public static void main(String[] args) {
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
   
    // instantiate cloner
    BookCloner988 bookCloner = new BookCloner988();
   
    // create clone
    Book clonedBook = bookCloner.apply(book);

    // clone should have same structure and values
    System.out.println(clonedBook.getAuthor()); //  John O'Farrel
    System.out.println(clonedBook.getSections().get(1).getName()); // Section2
    System.out.println(clonedBook.getSections().get(1).getParagraphs().iterator().next().getNumber()); // 1066
       
    // ..but every element of different reference
    System.out.println(clonedBook == book)// false
    System.out.println(clonedBook.getSections().get(1) == book.getSections().get(1)); // false
    System.out.println(clonedBook.getSections().get(1).getParagraphs().iterator().next() == book.getSections().get(1).getParagraphs().iterator().next()); // false
  }
View Full Code Here

   
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
   
    // instantiate cloner
    BookCloner987 bookCloner987 = new BookCloner987();
View Full Code Here

  public static void main(String[] args) {
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
   
    // instantiate cloner
    BookCloner988 bookCloner = new BookCloner988();
View Full Code Here

  public void createBeanCreateCloneThenCloneShouldHaveSameStructureAndValuesButEveryElementOfDifferentReference() {
   
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
View Full Code Here

public class SimpleApp {
  public static void main(String[] args) {
    // create some data
    // use a.b.m2.Book which has 1:N relations (collection) to other beans
    Book book = new Book("History of Britain", "John O'Farrel", ImmutableList.copyOf(new Section[] {
      new Section("Section1", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(1, "Bla bla bla"),
      })),
      new Section("Section2", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1066, "Bla bla bla"),
      })),
      new Section("Section3", "no description", ImmutableSet.copyOf(new Paragraph[] {
          new Paragraph(1, "Bla bla bla"),
          new Paragraph(2, "Bla bla bla"),
          new Paragraph(3, "Bla bla bla"),
      })),
    }));
View Full Code Here

    Body body = new Body();
    Mdiv mdiv = new Mdiv();
    Score score = new Score();
    ScoreDef scoreDef = createScoreDef(stavesCount);
    score.getGapsAndSbsAndCorrs().add(scoreDef);
    Section section = new Section();
    Measure measureFirst = new Measure();
    Staff staffFirst = new Staff();
    Layer layerFirst = new Layer();
    staffFirst.getSbsAndSymbolsAndOrigs().add(layerFirst);
    measureFirst.getAnnotsAndSlursAndTupletSpen().add(staffFirst);
    for (int stavesIter = 1; stavesIter < stavesCount; stavesIter++) {
      Staff staff = new Staff();
      Layer layer = new Layer();
      staff.getSbsAndSymbolsAndOrigs().add(layer);
      measureFirst.getAnnotsAndSlursAndTupletSpen().add(staff);
    }
    section.getUnclearsAndSbsAndApps().add(measureFirst);

    for (int measureIter = 1; measureIter < measureCount; measureIter++) {
      Measure measure = new Measure();
      for (int stavesIter = 0; stavesIter < stavesCount; stavesIter++) {
        Staff staff = new Staff();
        Layer layer = new Layer();
        staff.getSbsAndSymbolsAndOrigs().add(layer);
        measure.getAnnotsAndSlursAndTupletSpen().add(staff);
      }
      section.getUnclearsAndSbsAndApps().add(measure);
    }
    score.getGapsAndSbsAndCorrs().add(section);
    mdiv.setScore(score);
    body.getMdivs().add(mdiv);
    music.setBody(body);
View Full Code Here

    tpd.setDescription(MusicMessages.MEI_documentation_generic_n);
    descriptors.add(tpd);
  }
 
  private void createDefaultSection() {
    setMeiNode(new Section());
  }
View Full Code Here

  private static MeiNode handleScoreChild(BasicElement childForm,
      boolean saveAllVariants) {
    if (childForm instanceof SectionForm) {
      SectionForm sectionForm = (SectionForm) childForm;
      Section section = (Section) sectionForm.getMeiNode();
      section.getUnclearsAndSbsAndApps().clear();
      for (BasicElement sectionChildForm : sectionForm.getChildren()) {
        section.getUnclearsAndSbsAndApps().add(
            handleScoreChild(sectionChildForm, saveAllVariants));
      }
      return section;
    } else if (childForm instanceof EndingForm) {
      EndingForm endingForm = (EndingForm) childForm;
View Full Code Here

     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public Section createSectionFromString(EDataType eDataType, String initialValue) {
        Section result = Section.get(initialValue);
        if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
        return result;
    }
View Full Code Here

TOP

Related Classes of a.b.m2.Section

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.