Source:
ServicePolicy getServicePolicyFromLegacyPolicy(LegacyPolicy legacyPolicy) { List<ServicePolicy.Location> locations = null; if (legacyPolicy.getFences() != null) { if (!legacyPolicy.getFences().isEmpty()) { locations = new ArrayList<>(); for (Fence fence : legacyPolicy.getFences()) { if (fence instanceof GeoCircleFence) { locations.add(getLocationFromGeoCircleFence((GeoCircleFence) fence)); } } } } Integer requiredFactors = (legacyPolicy.getAmount() != 0) ? legacyPolicy.getAmount() : null; Boolean knowledgeFactorRequired = null; Boolean inherenceFactorRequired = null; Boolean possessionFactorRequired = null; if (legacyPolicy.isInherenceRequired() || legacyPolicy.isKnowledgeRequired() || legacyPolicy.isPossessionRequired()) { inherenceFactorRequired = legacyPolicy.isInherenceRequired(); knowledgeFactorRequired = legacyPolicy.isKnowledgeRequired(); possessionFactorRequired = legacyPolicy.isPossessionRequired(); } Boolean jailBreakProtectionEnabled = legacyPolicy.getDenyRootedJailbroken() ? true : null; List<ServicePolicy.TimeFence> timeFences = new ArrayList<>(); for (LegacyPolicy.TimeFence legacyPolicyTimefence : legacyPolicy.getTimeFences()) { List<ServicePolicy.Day> days = new ArrayList<>(); for (LegacyPolicy.Day day : legacyPolicyTimefence.getDays()) { days.add(ServicePolicy.Day.fromString(day.toString())); } timeFences.add(new ServicePolicy.TimeFence( legacyPolicyTimefence.getName(), days, legacyPolicyTimefence.getStartHour(), legacyPolicyTimefence.getStartMinute(), legacyPolicyTimefence.getEndHour(), legacyPolicyTimefence.getEndMinute(), legacyPolicyTimefence.getTimeZone()) ); } return new ServicePolicy(requiredFactors, knowledgeFactorRequired, inherenceFactorRequired, possessionFactorRequired, jailBreakProtectionEnabled, locations, timeFences); }

Target:
ServicePolicy getServicePolicyFromLegacyPolicy(LegacyPolicy legacyPolicy) { List<ServicePolicy.Location> locations = null; if (legacyPolicy.getFences() != null) { if (!legacyPolicy.getFences().isEmpty()) { locations = new ArrayList<>(); for (Fence fence : legacyPolicy.getFences()) { if (fence instanceof GeoCircleFence) { locations.add(getLocationFromGeoCircleFence((GeoCircleFence) fence)); } } } } Integer requiredFactors = (legacyPolicy.getAmount() != 0) ? legacyPolicy.getAmount() : null; Boolean knowledgeFactorRequired = null; Boolean inherenceFactorRequired = null; Boolean possessionFactorRequired = null; if (legacyPolicy.isInherenceRequired() || legacyPolicy.isKnowledgeRequired() || legacyPolicy.isPossessionRequired()) { inherenceFactorRequired = legacyPolicy.isInherenceRequired(); knowledgeFactorRequired = legacyPolicy.isKnowledgeRequired(); possessionFactorRequired = legacyPolicy.isPossessionRequired(); } Boolean jailBreakProtectionEnabled = legacyPolicy.getDenyRootedJailbroken() ? true : null; List<ServicePolicy.TimeFence> timeFences = new ArrayList<>(); for (LegacyPolicy.TimeFence legacyPolicyTimefence : legacyPolicy.getTimeRestrictions()) { List<ServicePolicy.Day> days = new ArrayList<>(); for (LegacyPolicy.Day day : legacyPolicyTimefence.getDays()) { days.add(ServicePolicy.Day.fromString(day.toString())); } timeFences.add(new ServicePolicy.TimeFence( legacyPolicyTimefence.getName(), days, legacyPolicyTimefence.getStartHour(), legacyPolicyTimefence.getStartMinute(), legacyPolicyTimefence.getEndHour(), legacyPolicyTimefence.getEndMinute(), legacyPolicyTimefence.getTimeZone()) ); } return new ServicePolicy(requiredFactors, knowledgeFactorRequired, inherenceFactorRequired, possessionFactorRequired, jailBreakProtectionEnabled, locations, timeFences); }