Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] adjusted lar enums to have blank value without using 0 #4354

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ sealed trait AutomatedUnderwritingResultEnum extends LarEnum

object AutomatedUnderwritingResultEnum
extends LarCodeEnum[AutomatedUnderwritingResultEnum] {
override val values = (0 to 24).toList :+ 1111
override val values = (1 to 24).toList :+ 1111

override def blankValue: AutomatedUnderwritingResultEnum = EmptyAUSResultValue

override def valueOf(code: Int): AutomatedUnderwritingResultEnum =
code match {
case 0 => EmptyAUSResultValue
case 1 => ApproveEligible
case 2 => ApproveIneligible
case 3 => ReferEligilbe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ sealed trait AutomatedUnderwritingSystemEnum extends LarEnum

object AutomatedUnderwritingSystemEnum
extends LarCodeEnum[AutomatedUnderwritingSystemEnum] {
override val values = List(0, 1, 2, 3, 4, 5, 6, 7, 1111)
override val values = List(1, 2, 3, 4, 5, 6, 7, 1111)

override def blankValue: AutomatedUnderwritingSystemEnum = EmptyAUSValue

override def valueOf(code: Int): AutomatedUnderwritingSystemEnum =
code match {
case 0 => EmptyAUSValue
case 1 => DesktopUnderwriter
case 2 => LoanProspector
case 3 => TechnologyOpenToApprovedLenders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package hmda.model.filing.lar.enums
sealed trait DenialReasonEnum extends LarEnum

object DenialReasonEnum extends LarCodeEnum[DenialReasonEnum] {
val values = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1111)
val values = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1111)

override def blankValue: DenialReasonEnum = EmptyDenialValue

def valueOf(code: Int): DenialReasonEnum =
code match {
case 0 => EmptyDenialValue
case 1 => DebtToIncomeRatio
case 2 => EmploymentHistory
case 3 => CreditHistory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package hmda.model.filing.lar.enums
sealed trait EthnicityEnum extends LarEnum

object EthnicityEnum extends LarCodeEnum[EthnicityEnum] {
override val values = List(0, 1, 11, 12, 13, 14, 2, 3, 4, 5)
override val values = List(1, 11, 12, 13, 14, 2, 3, 4, 5)

override def blankValue: EthnicityEnum = EmptyEthnicityValue

override def valueOf(code: Int): EthnicityEnum =
code match {
case 0 => EmptyEthnicityValue
case 1 => HispanicOrLatino
case 11 => Mexican
case 12 => PuertoRican
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ object LarEnum {

trait LarCodeEnum[+A] {
val values: List[Int]
def blankValue: A = throw new NotImplementedError
def valueOf(code: Int): A
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ sealed trait RaceEnum extends LarEnum

object RaceEnum extends LarCodeEnum[RaceEnum] {
override val values =
List(0, 1, 2, 21, 22, 23, 24, 25, 26, 27, 3, 4, 41, 42, 43, 44, 5, 6, 7, 8)
List(1, 2, 21, 22, 23, 24, 25, 26, 27, 3, 4, 41, 42, 43, 44, 5, 6, 7, 8)

override def blankValue: RaceEnum = EmptyRaceValue

override def valueOf(code: Int): RaceEnum =
code match {
case 0 => EmptyRaceValue
case 1 => AmericanIndianOrAlaskaNative
case 2 => Asian
case 21 => AsianIndian
Expand Down
7 changes: 5 additions & 2 deletions common/src/main/scala/hmda/parser/filing/lar/LarParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ trait LarParser {
def validateLarCodeOrEmptyField[A](larCodeEnum: LarCodeEnum[A],
value: String,
parserValidationError: ParserValidationError): LarParserValidationResult[A] =
if (value == "") {
larCodeEnum.valueOf(0).validNel
if (value.isBlank) {
Try(larCodeEnum.blankValue) match {
case Success(enum) => enum.validNel
case Failure(_) => parserValidationError.invalidNel
}
} else {
validateLarCode(larCodeEnum, value, parserValidationError)
}
Expand Down