private def asVacationPatch()

in server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/vacation/VacationResponseSet.scala [80:95]


  private def asVacationPatch(entry: (String, JsValue)): Either[IllegalArgumentException, VacationPatch.Builder] = entry match {
    case ("isEnabled", JsBoolean(bool)) => Right(VacationPatch.builder().isEnabled(bool))
    case ("isEnabled", JsNull) => Right(VacationPatch.builder().isEnabled(ValuePatch.remove[java.lang.Boolean]()))
    case ("fromDate", JsString(value)) => parseDate(value).map(date => VacationPatch.builder().fromDate(date))
    case ("fromDate", JsNull) => Right(VacationPatch.builder().fromDate(ValuePatch.remove[ZonedDateTime]()))
    case ("toDate", JsString(value)) => parseDate(value).map(date => VacationPatch.builder().toDate(date))
    case ("toDate", JsNull) => Right(VacationPatch.builder().toDate(ValuePatch.remove[ZonedDateTime]()))
    case ("subject", JsString(value)) => Right(VacationPatch.builder().subject(value))
    case ("subject", JsNull) => Right(VacationPatch.builder().subject(ValuePatch.remove[String]()))
    case ("textBody", JsString(value)) => Right(VacationPatch.builder().textBody(value))
    case ("textBody", JsNull) => Right(VacationPatch.builder().textBody(ValuePatch.remove[String]()))
    case ("htmlBody", JsString(value)) => Right(VacationPatch.builder().htmlBody(value))
    case ("htmlBody", JsNull) => Right(VacationPatch.builder().htmlBody(ValuePatch.remove[String]()))
    case ("id", _) => Left(new IllegalArgumentException("id is server-set thus cannot be changed"))
    case (unknownProperty, _) => Left(new IllegalArgumentException(s"$unknownProperty is an unknown property"))
  }