/**
     * Creates a builder by populating it with data from the given {@link
     * AgendaItemDefinitionContract}.
     *
     * @param contract the contract from which to populate this builder
     * @return an instance of the builder populated with data from the contract
     * @throws IllegalArgumentException if the contract is null
     */
    public static Builder create(AgendaItemDefinitionContract contract) {
      if (contract == null) {
        throw new IllegalArgumentException("contract is null");
      }
      Builder builder = new Builder(contract.getId(), contract.getAgendaId());
      builder.setRuleId(contract.getRuleId());
      builder.setSubAgendaId(contract.getSubAgendaId());
      builder.setWhenTrueId(contract.getWhenTrueId());
      builder.setWhenFalseId(contract.getWhenFalseId());
      builder.setAlwaysId(contract.getAlwaysId());

      if (contract.getRule() != null) {
        builder.setRule(RuleDefinition.Builder.create(contract.getRule()));
      }
      if (contract.getSubAgenda() != null) {
        builder.setSubAgenda(AgendaDefinition.Builder.create(contract.getSubAgenda()));
      }
      if (contract.getWhenTrue() != null) {
        builder.setWhenTrue(AgendaItemDefinition.Builder.create(contract.getWhenTrue()));
      }
      if (contract.getWhenFalse() != null) {
        builder.setWhenFalse(AgendaItemDefinition.Builder.create(contract.getWhenFalse()));
      }
      if (contract.getAlways() != null) {
        builder.setAlways(AgendaItemDefinition.Builder.create(contract.getAlways()));
      }
      builder.setVersionNumber(contract.getVersionNumber());
      return builder;
    }