Пример #1
0
  public static Plan fromJson(JsonCommand command) {
    final String planCode = command.stringValueOfParameterNamed("planCode");
    final String planDescription = command.stringValueOfParameterNamed("planDescription");
    final LocalDate startDate = command.localDateValueOfParameterNamed("startDate");
    final LocalDate endDate = command.localDateValueOfParameterNamed("endDate");
    final Long status = command.longValueOfParameterNamed("status");
    final Long billRule = command.longValueOfParameterNamed("billRule");
    final String provisioingSystem = command.stringValueOfParameterNamed("provisioingSystem");
    boolean isPrepaid = command.booleanPrimitiveValueOfParameterNamed("isPrepaid");
    boolean allowTopup = command.booleanPrimitiveValueOfParameterNamed("allowTopup");
    boolean isHwReq = command.booleanPrimitiveValueOfParameterNamed("isHwReq");

    return new Plan(
        planCode,
        planDescription,
        startDate,
        endDate,
        billRule,
        status,
        null,
        provisioingSystem,
        isPrepaid,
        allowTopup,
        isHwReq);
  }
Пример #2
0
  public Map<String, Object> update(JsonCommand command) {

    final Map<String, Object> actualChanges = new LinkedHashMap<String, Object>(1);
    final String firstnameParamName = "planCode";
    if (command.isChangeInStringParameterNamed(firstnameParamName, this.planCode)) {
      final String newValue = command.stringValueOfParameterNamed(firstnameParamName);
      actualChanges.put(firstnameParamName, newValue);
      this.planCode = StringUtils.defaultIfEmpty(newValue, null);
    }
    final String descriptionParamName = "planDescription";
    if (command.isChangeInStringParameterNamed(descriptionParamName, this.description)) {
      final String newValue = command.stringValueOfParameterNamed(descriptionParamName);
      actualChanges.put(firstnameParamName, newValue);
      this.description = StringUtils.defaultIfEmpty(newValue, null);
    }
    final String provisioingSystem = "provisioingSystem";
    if (command.isChangeInStringParameterNamed(provisioingSystem, this.provisionSystem)) {
      final String newValue = command.stringValueOfParameterNamed(provisioingSystem);
      actualChanges.put(provisioingSystem, newValue);
      this.provisionSystem = StringUtils.defaultIfEmpty(newValue, null);
    }

    final String startDateParamName = "startDate";
    if (command.isChangeInLocalDateParameterNamed(
        startDateParamName, new LocalDate(this.startDate))) {
      final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName);
      actualChanges.put(startDateParamName, newValue);
      this.startDate = newValue.toDate();
    }

    final String endDateParamName = "endDate";
    if (command.isChangeInLocalDateParameterNamed(endDateParamName, new LocalDate(this.endDate))) {
      final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName);
      actualChanges.put(endDateParamName, newValue);
      if (newValue != null) this.endDate = newValue.toDate();
    }
    final String billRuleParamName = "billRule";
    if (command.isChangeInLongParameterNamed(billRuleParamName, this.billRule)) {
      final Long newValue = command.longValueOfParameterNamed(billRuleParamName);
      actualChanges.put(billRuleParamName, newValue);
      this.billRule = newValue;
    }
    final String statusParamName = "status";
    if (command.isChangeInLongParameterNamed(statusParamName, this.status)) {
      final Long newValue = command.longValueOfParameterNamed(statusParamName);
      actualChanges.put(statusParamName, newValue);
      this.status = newValue;
    }
    final boolean isPrepaid = command.booleanPrimitiveValueOfParameterNamed("isPrepaid");
    final char isPrepaidParamName = isPrepaid ? 'Y' : 'N';
    this.isPrepaid = isPrepaidParamName;

    final boolean allowTopupParamName = command.booleanPrimitiveValueOfParameterNamed("allowTopup");
    this.allowTopup = allowTopupParamName ? 'Y' : 'N';

    final boolean isHwReqParamName = command.booleanPrimitiveValueOfParameterNamed("isHwReq");
    this.isHwReq = isHwReqParamName ? 'Y' : 'N';
    return actualChanges;
  }