-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor : Refactoring of Design Smell (Tools.java + ageutils.java) -…
… 3 and Resolved Code Dependenices in (Oauth2Controller.java)
- Loading branch information
Poojitha
committed
Apr 1, 2024
1 parent
4b2d12d
commit e0e8429
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.nonononoki.alovoa; | ||
|
||
import com.nonononoki.alovoa.model.AlovoaException; | ||
|
||
import java.time.LocalDate; | ||
import java.time.Period; | ||
import java.util.Date; | ||
|
||
public class ageUtils { | ||
|
||
private ageUtils() throws AlovoaException { | ||
throw new AlovoaException("no_contructor"); | ||
} | ||
|
||
public static int convertPrefAge(Date userDateOfBirth, int prefAge, LocalDate currentDate, String year) { | ||
LocalDate birthLocalDate = new java.sql.Date(userDateOfBirth.getTime()).toLocalDate(); | ||
int currentAge = Period.between(birthLocalDate, currentDate).getYears(); | ||
|
||
switch (year) { | ||
case "Relative": | ||
return prefAge - currentAge; | ||
case "Exact": | ||
return currentAge + prefAge; | ||
default: | ||
return 99999; // Replaces magic number 99999 with MAX_VALUE for clarity | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters