-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #336 from vaskocuturilo/dv000288_fix_british_regio…
…n_parse_plates DV-000288: Fix British region parse plates
- Loading branch information
Showing
8 changed files
with
91 additions
and
43 deletions.
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
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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/regions/simpleregions/util/DetailPlate.java
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,26 @@ | ||
package com.regions.simpleregions.util; | ||
|
||
public class DetailPlate { | ||
private DetailPlate() { | ||
throw new IllegalStateException("Utility class"); | ||
} | ||
|
||
public static RegionParse getPlateDetail(final String region) { | ||
int letter = 0; | ||
int number = 0; | ||
int space = 0; | ||
|
||
for (char c : region.toCharArray()) { | ||
if (Character.isLetter(c)) { | ||
letter++; | ||
} else if (Character.isDigit(c)) { | ||
number++; | ||
} else if (Character.isSpaceChar(c)) { | ||
space++; | ||
} else { | ||
throw new IllegalStateException("This item is incorrect"); | ||
} | ||
} | ||
return new RegionParse(letter, number, space); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/regions/simpleregions/util/RegionParse.java
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,14 @@ | ||
package com.regions.simpleregions.util; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class RegionParse { | ||
private int letter; | ||
private int number; | ||
private int space; | ||
} |
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
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
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