Source:
public Subscription fabricateSubscriptionFromPool(Pool pool) { if (pool == null) { throw new IllegalArgumentException("pool is null"); } Long poolQuantity = pool.getQuantity(); Long multiplier = 1L; if (pool.getProduct() != null) { multiplier = pool.getProduct().getMultiplier(); } else { log.error("Master product for the pool %s is null", pool.getId()); } if (poolQuantity != null && multiplier != null && pool.getProduct() != null) { if (poolQuantity % multiplier != 0) { log.error(String.format("Pool %s from which we fabricate " + "subscription has quantity %d that is not divisable " + "by its product's multiplier %d! Division wont be made.", pool.getId(), poolQuantity, multiplier)); } else { poolQuantity /= multiplier; } if (pool.getProduct().hasAttribute("instance_multiplier") && pool.getUpstreamPoolId() == null) { Integer instMult = null; String stringInstmult = pool.getProduct().getAttributeValue("instance_multiplier"); try { instMult = Integer.parseInt(stringInstmult); } catch (NumberFormatException nfe) { log.error("Instance multilier couldn't be parsed: " + stringInstmult); } if (instMult != null && poolQuantity % instMult == 0) { poolQuantity /= instMult; } else { log.error("Cannot divide pool quantity by instance multiplier. Won't touch the " + "current value %d " + "instance multiplier: %d, pool quantity: %d", poolQuantity, instMult, poolQuantity); } } } else { log.warn("Either quantity or multiplier or product is null:" + " %d, %d, productInstance=%s", poolQuantity, multiplier, pool.getProduct()); } Subscription fabricated = new Subscription( pool.getOwner(), pool.getProduct(), pool.getProvidedProducts(), poolQuantity, pool.getStartDate(), pool.getEndDate(), pool.getUpdated() ); fabricated.setId(pool.getSubscriptionId()); fabricated.setUpstreamEntitlementId(pool.getUpstreamEntitlementId()); fabricated.setCdn(pool.getCdn()); fabricated.setCertificate(pool.getCertificate()); fabricated.setBranding(pool.getBranding()); return fabricated; }

Target:
public Subscription fabricateSubscriptionFromPool(Pool pool) { if (pool == null) { throw new IllegalArgumentException("pool is null"); } Long poolQuantity = pool.getQuantity(); Long multiplier = 1L; if (pool.getProduct() != null) { multiplier = pool.getProduct().getMultiplier(); } else { log.error("Master product for the pool is null", pool.getId()); } if (poolQuantity != null && multiplier != null && multiplier != 0 && pool.getProduct() != null) { if (poolQuantity % multiplier != 0) { log.error("Pool from which we fabricate " + "subscription has quantity that is not divisable " + "by its product's multiplier {}! Division wont be made.", pool.getId(), poolQuantity, multiplier); } else { poolQuantity /= multiplier; } if (pool.getProduct().hasAttribute("instance_multiplier") && pool.getUpstreamPoolId() == null) { Integer instMult = null; String stringInstmult = pool.getProduct().getAttributeValue("instance_multiplier"); try { instMult = Integer.parseInt(stringInstmult); } catch (NumberFormatException nfe) { log.error("Instance multilier couldn't be parsed: ", stringInstmult); } if (instMult != null && instMult != 0 && poolQuantity % instMult == 0) { poolQuantity /= instMult; } else { log.error("Cannot divide pool quantity by instance multiplier. Won't touch the " + "current value " + "instance multiplier: {}, pool quantity: {}", poolQuantity, instMult, poolQuantity); } } } else { log.warn("Either quantity or multiplier or product is null:" + " {}, {}, productInstance={}", poolQuantity, multiplier, pool.getProduct()); } Subscription fabricated = new Subscription( pool.getOwner(), pool.getProduct(), pool.getProvidedProducts(), poolQuantity, pool.getStartDate(), pool.getEndDate(), pool.getUpdated() ); fabricated.setId(pool.getSubscriptionId()); fabricated.setUpstreamEntitlementId(pool.getUpstreamEntitlementId()); fabricated.setCdn(pool.getCdn()); fabricated.setCertificate(pool.getCertificate()); fabricated.setBranding(pool.getBranding()); return fabricated; }