Buggy code:
@ Domain public class Tariff { private static Logger log = Logger . getLogger ( Tariff . class . getName ( ) ) ; public enum State { PENDING , OFFERED , ACTIVE , WITHDRAWN , KILLED ; } private TimeService timeService ; private TariffRepo tariffRepo ; private long specId ; private TariffSpecification tariffSpec ; private Broker broker ; private Tariff . State state = Tariff . State . PENDING ; private Tariff isSupersededBy ; double totalCost = 0.0 ; double totalUsage = 0.0 ; private Instant offerDate ; private Instant expiration ; private boolean isWeekly = false ; private boolean analyzed = false ; private HashMap < Long , Rate > rateIdMap ; private TreeSet < Double > tiers ; private int tierSign = 1 ; private Rate [ ] [ ] rateMap ; private RegulationRate regulationRate ; public Tariff ( TariffSpecification spec ) { } public boolean init ( ) { } public TariffSpecification getTariffSpecification ( ) { } public long getSpecId ( ) { } public long getId ( ) { } void setId ( long id ) { } @ StateChange public boolean addHourlyCharge ( HourlyCharge newCharge , long rateId ) { } public double getRealizedPrice ( ) { } public long getMinDuration ( ) { } public PowerType getPowerType ( ) { } public double getSignupPayment ( ) { } public double getEarlyWithdrawPayment ( ) { } public double getPeriodicPayment ( ) { } public double getMaxUpRegulation ( double kwh , double cumulativeUsage ) { } public double getUsageCharge ( double kwh , double cumulativeUsage , boolean recordUsage ) { } public double getRegulationCharge ( double kwh , double cumulativeUsage , boolean recordUsage ) { } public double getUsageCharge ( Instant when , double kwh , double cumulativeUsage ) { } public double getUsageCharge ( Instant when , double kwh , double cumulativeUsage , TariffEvaluationHelper helper ) { } private double applyRegulationAdjustment ( double value , double kwh , TariffEvaluationHelper helper ) { <START_BUG> if ( ( null == helper ) || ( ! ( this . hasRegulationRate ( ) ) ) ) <END_BUG> return value ; double p1 = getRegulationCharge ( ( ( helper . getExpectedCurtailment ( ) ) // kwh ) , 0.0 , false ) ; double p2 = getRegulationCharge ( ( ( helper . getExpectedDischarge ( ) ) // kwh ) , 0.0 , false ) ; double p3 = getRegulationCharge ( ( ( helper . getExpectedDownRegulation ( ) ) // kwh ) , 0.0 , false ) ; double result = ( ( ( value * ( 1.0 - ( ( ( helper . getExpectedDischarge ( ) ) + ( helper . getExpectedDownRegulation ( ) ) ) // kwh ) ) ) - p1 ) + p2 ) + p3 ; return result ; } private int getTimeIndex ( Instant when ) { } public Instant getExpiration ( ) { } public boolean isExpired ( ) { } @ StateChange public void setExpiration ( Instant newDate ) { } public Instant getOfferDate ( ) { } public boolean isCovered ( ) { } public TariffSpecification getTariffSpec ( ) { } public Broker getBroker ( ) { } public Tariff . State getState ( ) { } @ StateChange public void setState ( Tariff . State newState ) { } public boolean isActive ( ) { } public Tariff getIsSupersededBy ( ) { } public double getTotalCost ( ) { } public double getTotalUsage ( ) { } public boolean isWeekly ( ) { } public boolean isRevoked ( ) { } public boolean isSubscribable ( ) { } public boolean isTimeOfUse ( ) { } public boolean isTiered ( ) { } public boolean isVariableRate ( ) { } public boolean isInterruptible ( ) { } public boolean hasRegulationRate ( ) { } private void analyze ( ) { } private List < Tariff . RateKwh > getRateKwhList ( int timeIndex , double kwh , double cumulativeUsage ) { } private Rate findRate ( int tierIndex , int timeIndex ) { } public boolean isAnalyzed ( ) { } class RateKwh { Rate rate ; double kwh ; RateKwh ( Rate rate , double kwh ) { } } }

Fix:
if ( ( ( null == helper ) || ( kwh == 0.0 ) ) || ( ! ( this . hasRegulationRate ( ) ) ) )