public RelationalGroup derive(final boolean preserveElementInstanceIds) {
    final RelationalGroup g = (RelationalGroup) super.derive(preserveElementInstanceIds);
    g.footer = (GroupFooter) footer.derive(preserveElementInstanceIds);
    g.header = (GroupHeader) header.derive(preserveElementInstanceIds);

    g.registerAsChild(g.footer);
    g.registerAsChild(g.header);
    return g;
  }
  /**
   * Clones this Element.
   *
   * @return a clone of this element.
   */
  public RelationalGroup clone() {
    final RelationalGroup g = (RelationalGroup) super.clone();
    g.footer = (GroupFooter) footer.clone();
    g.header = (GroupHeader) header.clone();

    g.registerAsChild(g.footer);
    g.registerAsChild(g.header);
    return g;
  }
  /**
   * Checks whether the group is equal. A group is considered equal to another group, if it defines
   * the same fields as the other group.
   *
   * @param obj the object to be checked
   * @return true, if the object is a group instance with the same fields, false otherwise.
   */
  public boolean equals(final Object obj) {
    if (this == obj) {
      return true;
    }
    if (!(obj instanceof RelationalGroup)) {
      return false;
    }

    final RelationalGroup group = (RelationalGroup) obj;
    final String[] otherFields = group.getFieldsArray();
    final String[] myFields = getFieldsArray();
    if (ObjectUtilities.equalArray(otherFields, myFields) == false) {
      return false;
    }
    return true;
  }
  @Deprecated
  public GroupDataBody findGroupDataBody() {
    final GroupBody body = getBody();
    if (body instanceof GroupDataBody) {
      return (GroupDataBody) body;
    }
    if (body instanceof SubGroupBody) {
      final SubGroupBody groupBody = (SubGroupBody) body;
      final Group group = groupBody.getGroup();
      if (group instanceof RelationalGroup) {
        final RelationalGroup rg = (RelationalGroup) group;
        return rg.findGroupDataBody();
      }
    }

    return null;
  }
 public void testCreate() throws Exception {
   final RelationalGroup g1 = new RelationalGroup();
   assertNotNull(g1.clone());
   assertNotNull(g1.getFields());
   assertNotNull(g1.getFooter());
   assertNotNull(g1.getHeader());
   assertNotNull(g1.getName());
   assertNotNull(g1.toString());
 }
  public void testMethods() {
    final RelationalGroup g = new RelationalGroup();

    try {
      g.setHeader(null);
      fail();
    } catch (NullPointerException npe) {
      // expected, ignored
    }
    try {
      g.setFooter(null);
      fail();
    } catch (NullPointerException npe) {
      // expected, ignored
    }
    try {
      g.addField(null);
      fail();
    } catch (NullPointerException npe) {
      // expected, ignored
    }
  }
  public void testResourceLabelAfterSerialization() throws Exception {
    final File url = GoldTestBase.locateGoldenSampleReport("Prd-3514.prpt");
    assertNotNull(url);
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    final Resource directly = resourceManager.createDirectly(url, MasterReport.class);
    final MasterReport org = (MasterReport) directly.getResource();

    final MasterReport report = postProcess(org);

    RelationalGroup relationalGroup = report.getRelationalGroup(0);
    GroupHeader header = relationalGroup.getHeader();
    Band band = (Band) header.getElement(0);
    Element element = band.getElement(1);
    assertTrue(element.getElementType() instanceof ResourceMessageType);
    element.setName("DateTitleField");
    //    LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(report, 1);
    LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, header, false, false);
    RenderNode dateTitleField = MatchFactory.findElementByName(logicalPageBox, "DateTitleField");
    assertNotNull(dateTitleField);
    //    ModelPrinter.INSTANCE.print(logicalPageBox);
  }
 private static RelationalGroup createGroup(String name, String[] fields) {
   final RelationalGroup group = new RelationalGroup();
   group.setFields(Arrays.asList(fields));
   group.setName(name);
   return group;
 }