Skip to content

Commit

Permalink
PathDetailsBuilderFactory: reduce from EncodingManager to EncodedValu…
Browse files Browse the repository at this point in the history
…eLookup
  • Loading branch information
karussell committed Nov 28, 2019
1 parent 80af196 commit b600ddb
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class PathDetailsBuilderFactory {

public List<PathDetailsBuilder> createPathDetailsBuilders(List<String> requestedPathDetails, EncodingManager em, Weighting weighting) {
public List<PathDetailsBuilder> createPathDetailsBuilders(List<String> requestedPathDetails, EncodedValueLookup evl, Weighting weighting) {
List<PathDetailsBuilder> builders = new ArrayList<>();

if (requestedPathDetails.contains(AVERAGE_SPEED))
Expand All @@ -59,14 +59,14 @@ public List<PathDetailsBuilder> createPathDetailsBuilders(List<String> requested
builders.add(new DistanceDetails());

for (String checkSuffix : requestedPathDetails) {
if (checkSuffix.contains(getKey("", "priority")) && em.hasEncodedValue(checkSuffix))
builders.add(new DecimalDetails(checkSuffix, em.getDecimalEncodedValue(checkSuffix)));
if (checkSuffix.contains(getKey("", "priority")) && evl.hasEncodedValue(checkSuffix))
builders.add(new DecimalDetails(checkSuffix, evl.getDecimalEncodedValue(checkSuffix)));
}

for (String key : Arrays.asList(MaxSpeed.KEY, MaxWidth.KEY, MaxHeight.KEY, MaxWeight.KEY,
MaxAxleLoad.KEY, MaxLength.KEY)) {
if (requestedPathDetails.contains(key) && em.hasEncodedValue(key))
builders.add(new DecimalDetails(key, em.getDecimalEncodedValue(key)));
if (requestedPathDetails.contains(key) && evl.hasEncodedValue(key))
builders.add(new DecimalDetails(key, evl.getDecimalEncodedValue(key)));
}

for (Map.Entry entry : Arrays.asList(new MapEntry<>(RoadClass.KEY, RoadClass.class),
Expand All @@ -76,8 +76,8 @@ public List<PathDetailsBuilder> createPathDetailsBuilders(List<String> requested
new MapEntry<>(HazmatTunnel.KEY, HazmatTunnel.class), new MapEntry<>(HazmatWater.KEY, HazmatWater.class),
new MapEntry<>(Country.KEY, Country.class))) {
String key = (String) entry.getKey();
if (requestedPathDetails.contains(key) && em.hasEncodedValue(key))
builders.add(new EnumDetails(key, em.getEnumEncodedValue(key, (Class<Enum>) entry.getValue())));
if (requestedPathDetails.contains(key) && evl.hasEncodedValue(key))
builders.add(new EnumDetails(key, evl.getEnumEncodedValue(key, (Class<Enum>) entry.getValue())));
}

if (requestedPathDetails.size() != builders.size()) {
Expand Down

0 comments on commit b600ddb

Please sign in to comment.