@Test public void testShippingSummary() { final Reward rewardWithNullShipping = RewardFactory.reward() .toBuilder() .shippingType(null) .build(); assertNull(RewardUtils.shippingSummary(rewardWithNullShipping)); final Reward rewardWithNoShipping = RewardFactory.reward(); assertNull(RewardUtils.shippingSummary(rewardWithNoShipping)); final Reward rewardWithMultipleLocationShipping = RewardFactory.multipleLocationShipping(); assertEquals(Pair.create(R.string.Limited_shipping, null), RewardUtils.shippingSummary(rewardWithMultipleLocationShipping)); final Reward rewardWithSingleLocationShipping = RewardFactory.singleLocationShipping(LocationFactory.nigeria().displayableName()); assertEquals(Pair.create(R.string.location_name_only, "Nigeria"), RewardUtils.shippingSummary(rewardWithSingleLocationShipping)); final Reward rewardWithWorldWideShipping = RewardFactory.rewardWithShipping(); assertEquals(Pair.create(R.string.Ships_worldwide, null), RewardUtils.shippingSummary(rewardWithWorldWideShipping)); }
public static Pair<Integer, String> shippingSummary(final @NonNull Reward reward) { final String shippingType = reward.shippingType(); if (!RewardUtils.isShippable(reward) || shippingType == null) { return null; } switch (shippingType) { case Reward.SHIPPING_TYPE_ANYWHERE: return Pair.create(R.string.Ships_worldwide, null); case Reward.SHIPPING_TYPE_MULTIPLE_LOCATIONS: return Pair.create(R.string.Limited_shipping, null); case Reward.SHIPPING_TYPE_SINGLE_LOCATION: final Reward.SingleLocation location = reward.shippingSingleLocation(); if (ObjectUtils.isNotNull(location)) { return Pair.create(R.string.location_name_only, location.localizedName()); } else { return Pair.create(R.string.Limited_shipping, null); } } return null; }
RewardUtils { public static Pair<Integer, String> shippingSummary(final @NonNull Reward reward) { final String shippingType = reward.shippingType(); if (!RewardUtils.isShippable(reward) || shippingType == null) { return null; } switch (shippingType) { case Reward.SHIPPING_TYPE_ANYWHERE: return Pair.create(R.string.Ships_worldwide, null); case Reward.SHIPPING_TYPE_MULTIPLE_LOCATIONS: return Pair.create(R.string.Limited_shipping, null); case Reward.SHIPPING_TYPE_SINGLE_LOCATION: final Reward.SingleLocation location = reward.shippingSingleLocation(); if (ObjectUtils.isNotNull(location)) { return Pair.create(R.string.location_name_only, location.localizedName()); } else { return Pair.create(R.string.Limited_shipping, null); } } return null; } }
RewardUtils { public static Pair<Integer, String> shippingSummary(final @NonNull Reward reward) { final String shippingType = reward.shippingType(); if (!RewardUtils.isShippable(reward) || shippingType == null) { return null; } switch (shippingType) { case Reward.SHIPPING_TYPE_ANYWHERE: return Pair.create(R.string.Ships_worldwide, null); case Reward.SHIPPING_TYPE_MULTIPLE_LOCATIONS: return Pair.create(R.string.Limited_shipping, null); case Reward.SHIPPING_TYPE_SINGLE_LOCATION: final Reward.SingleLocation location = reward.shippingSingleLocation(); if (ObjectUtils.isNotNull(location)) { return Pair.create(R.string.location_name_only, location.localizedName()); } else { return Pair.create(R.string.Limited_shipping, null); } } return null; } private  RewardUtils(); }
RewardUtils { public static Pair<Integer, String> shippingSummary(final @NonNull Reward reward) { final String shippingType = reward.shippingType(); if (!RewardUtils.isShippable(reward) || shippingType == null) { return null; } switch (shippingType) { case Reward.SHIPPING_TYPE_ANYWHERE: return Pair.create(R.string.Ships_worldwide, null); case Reward.SHIPPING_TYPE_MULTIPLE_LOCATIONS: return Pair.create(R.string.Limited_shipping, null); case Reward.SHIPPING_TYPE_SINGLE_LOCATION: final Reward.SingleLocation location = reward.shippingSingleLocation(); if (ObjectUtils.isNotNull(location)) { return Pair.create(R.string.location_name_only, location.localizedName()); } else { return Pair.create(R.string.Limited_shipping, null); } } return null; } private  RewardUtils(); static boolean hasBackers(final @NonNull Reward reward); static boolean isAvailable(final @NonNull Project project, final @NonNull Reward reward); static boolean isExpired(final @NonNull Reward reward); static boolean isItemized(final @NonNull Reward reward); static boolean isLimited(final @NonNull Reward reward); static boolean isLimitReached(final @NonNull Reward reward); static boolean isNoReward(final @NonNull Reward reward); static boolean isReward(final @NonNull Reward reward); static boolean isShippable(final @NonNull Reward reward); static boolean isTimeLimited(final @NonNull Reward reward); static @NonNull String deadlineCountdownDetail(final @NonNull Reward reward, final @NonNull Context context,
    final @NonNull KSString ksString); static @NonNull String deadlineCountdownUnit(final @NonNull Reward reward, final @NonNull Context context); static Pair<Integer, String> shippingSummary(final @NonNull Reward reward); static @NonNull Long timeInSecondsUntilDeadline(final @NonNull Reward reward); static int deadlineCountdownValue(final @NonNull Reward reward); static Double rewardAmountByVariant(final OptimizelyExperiment.Variant variant, final Reward reward, final Integer minPledge); }
RewardUtils { public static Pair<Integer, String> shippingSummary(final @NonNull Reward reward) { final String shippingType = reward.shippingType(); if (!RewardUtils.isShippable(reward) || shippingType == null) { return null; } switch (shippingType) { case Reward.SHIPPING_TYPE_ANYWHERE: return Pair.create(R.string.Ships_worldwide, null); case Reward.SHIPPING_TYPE_MULTIPLE_LOCATIONS: return Pair.create(R.string.Limited_shipping, null); case Reward.SHIPPING_TYPE_SINGLE_LOCATION: final Reward.SingleLocation location = reward.shippingSingleLocation(); if (ObjectUtils.isNotNull(location)) { return Pair.create(R.string.location_name_only, location.localizedName()); } else { return Pair.create(R.string.Limited_shipping, null); } } return null; } private  RewardUtils(); static boolean hasBackers(final @NonNull Reward reward); static boolean isAvailable(final @NonNull Project project, final @NonNull Reward reward); static boolean isExpired(final @NonNull Reward reward); static boolean isItemized(final @NonNull Reward reward); static boolean isLimited(final @NonNull Reward reward); static boolean isLimitReached(final @NonNull Reward reward); static boolean isNoReward(final @NonNull Reward reward); static boolean isReward(final @NonNull Reward reward); static boolean isShippable(final @NonNull Reward reward); static boolean isTimeLimited(final @NonNull Reward reward); static @NonNull String deadlineCountdownDetail(final @NonNull Reward reward, final @NonNull Context context,
    final @NonNull KSString ksString); static @NonNull String deadlineCountdownUnit(final @NonNull Reward reward, final @NonNull Context context); static Pair<Integer, String> shippingSummary(final @NonNull Reward reward); static @NonNull Long timeInSecondsUntilDeadline(final @NonNull Reward reward); static int deadlineCountdownValue(final @NonNull Reward reward); static Double rewardAmountByVariant(final OptimizelyExperiment.Variant variant, final Reward reward, final Integer minPledge);  }