test_class.file: series/src/test/java/com/barchart/feed/series/TimeFrameImplTest.java
test_class.identifier: TimeFrameImplTest
test_case.body: @Test
      public void testIsDerivableFrom() {
          
          //////////////////////////////////////////////////////////
          ////   First test derivable Periods (no date checks)  ////
          //////////////////////////////////////////////////////////
          
          DateTime dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          TimeFrameImpl tf1 = new TimeFrameImpl(new Period(PeriodType.TICK, 1), dt1, null);
          
          DateTime dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          TimeFrameImpl tf2 = new TimeFrameImpl(new Period(PeriodType.SECOND, 1), dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.SECOND, 1), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(Period.ONE_MINUTE, dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 1), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(Period.ONE_HOUR, dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(Period.ONE_HOUR, dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(Period.DAY, dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(Period.DAY, dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(Period.WEEK, dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          //Above pattern breaks down here - nothing can be derived from weeks
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(Period.WEEK, dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(Period.MONTH, dt2, null);
          
          assertFalse(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(Period.MONTH, dt1, null);
          
          //Pattern returns as viable her
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(Period.QUARTER, dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(Period.QUARTER, dt1, null);
          
          //Pattern returns as viable her
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(Period.YEAR, dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          assertFalse(tf1.isDerivableFrom(tf2));
          
          //////////////////////////////////////////////////////////
          ////               Test Derivable Durations           ////
          //////////////////////////////////////////////////////////
          //5Min derivable from 1M
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(Period.ONE_MINUTE, dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          
          //5Min !Derivable from 5Min
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          
          //10Min Derivable from 5Min *IF* 2 % 1 == 0 and startDates are same and endDate1 == null or endDates are equal
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));
          
          //10Min Derivable from 5Min *IF* 2 % 1 == 0 and startDates are same and endDate1 == null or endDates are equal == (not due to 10 % 6)
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 6), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, null);
          
          assertFalse(tf2.isDerivableFrom(tf1));
          
          //10Min Derivable from 5Min *IF* 2 % 1 == 0 and startDates are same and endDate1 == null or endDates are equal == (not due to startDates !=)
          dt1 = new DateTime(2013, 12, 10, 11, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, null);
          
          assertFalse(tf2.isDerivableFrom(tf1));
          
          /////////////////// Test end date conditions ////////////////////
          //Derive source end date is not null and derive from is --> false
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt1, new DateTime(2013, 12, 20, 12, 0, 0));
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, null);
          
          assertFalse(tf2.isDerivableFrom(tf1));
          
          //Derive source end date is null and derive from is not --> true
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, new DateTime(2013, 12, 20, 12, 0, 0));
          
          assertTrue(tf2.isDerivableFrom(tf1));
          
          //End dates are equal --> true
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 5), dt1, new DateTime(2013, 12, 20, 12, 0, 0));
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, new DateTime(2013, 12, 20, 12, 0, 0));
          
          assertTrue(tf2.isDerivableFrom(tf1));
          
          
          //////////////////////////////////////////////////////////
          ////                Date boundary checks              ////
          //////////////////////////////////////////////////////////
          //Normal - isDerivable
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 1), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, null);
          
          assertTrue(tf2.isDerivableFrom(tf1));//new DateTime(2013, 12, 30, 12, 0, 0)
          
          //First frame's start after 2nd causes failure
          dt1 = new DateTime(2013, 12, 10, 13, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 1), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, null);
          
          assertFalse(tf2.isDerivableFrom(tf1));
          
          //2nd having end date, while first has no end date, does NOT cause failure 
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 1), dt1, null);
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, new DateTime(2013, 12, 30, 12, 0, 0));
          
          assertTrue(tf2.isDerivableFrom(tf1));
          
          //First having end date while 2nd not having end date causes failure
          dt1 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf1 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 1), dt1, new DateTime(2013, 12, 30, 12, 0, 0));
          
          dt2 = new DateTime(2013, 12, 10, 12, 0, 0);
          tf2 = new TimeFrameImpl(new Period(PeriodType.MINUTE, 10), dt2, null);
          
          assertFalse(tf2.isDerivableFrom(tf1));
          
          
      }
test_case.class_method_signature: TimeFrameImplTest.testIsDerivableFrom()
test_case.full_signature: @Test public void testIsDerivableFrom()
test_case.identifier: testIsDerivableFrom
test_case.invocations: assertTrue isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertFalse isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertTrue isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertFalse isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertTrue isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom assertTrue isDerivableFrom assertFalse isDerivableFrom
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIsDerivableFrom()
focal_class.declarator: period
focal_class.modifier: private
focal_class.original_string: private Period period;
focal_class.type: Period
focal_class.var_name: period
focal_class.declarator: startDate
focal_class.modifier: private
focal_class.original_string: private DateTime startDate;
focal_class.type: DateTime
focal_class.var_name: startDate
focal_class.declarator: endDate
focal_class.modifier: private
focal_class.original_string: private DateTime endDate;
focal_class.type: DateTime
focal_class.var_name: endDate
focal_class.file: series/src/main/java/com/barchart/feed/series/TimeFrameImpl.java
focal_class.identifier: TimeFrameImpl
focal_class.interfaces: implements TimeFrame
focal_class.class_method_signature: TimeFrameImpl.TimeFrameImpl(Period period, DateTime startDate, DateTime endDate)
focal_class.full_signature: public  TimeFrameImpl(Period period, DateTime startDate, DateTime endDate)
focal_class.identifier: TimeFrameImpl
focal_class.modifiers: public
focal_class.parameters: (Period period, DateTime startDate, DateTime endDate)
focal_class.signature:  TimeFrameImpl(Period period, DateTime startDate, DateTime endDate)
focal_class.class_method_signature: TimeFrameImpl.getPeriod()
focal_class.full_signature: @Override public Period getPeriod()
focal_class.identifier: getPeriod
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Period
focal_class.signature: Period getPeriod()
focal_class.class_method_signature: TimeFrameImpl.getStartDate()
focal_class.full_signature: @Override public DateTime getStartDate()
focal_class.identifier: getStartDate
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: DateTime
focal_class.signature: DateTime getStartDate()
focal_class.class_method_signature: TimeFrameImpl.getEndDate()
focal_class.full_signature: @Override public DateTime getEndDate()
focal_class.identifier: getEndDate
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: DateTime
focal_class.signature: DateTime getEndDate()
focal_class.class_method_signature: TimeFrameImpl.isDerivableFrom(TimeFrame tf)
focal_class.full_signature: @Override public boolean isDerivableFrom(TimeFrame tf)
focal_class.identifier: isDerivableFrom
focal_class.modifiers: @Override public
focal_class.parameters: (TimeFrame tf)
focal_class.return: boolean
focal_class.signature: boolean isDerivableFrom(TimeFrame tf)
focal_class.class_method_signature: TimeFrameImpl.areEqualOrNull(DateTime otherDate, DateTime endDate2)
focal_class.full_signature: private boolean areEqualOrNull(DateTime otherDate, DateTime endDate2)
focal_class.identifier: areEqualOrNull
focal_class.modifiers: private
focal_class.parameters: (DateTime otherDate, DateTime endDate2)
focal_class.return: boolean
focal_class.signature: boolean areEqualOrNull(DateTime otherDate, DateTime endDate2)
focal_class.class_method_signature: TimeFrameImpl.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: TimeFrameImpl.equals(Object obj)
focal_class.full_signature: @Override public boolean equals(Object obj)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object obj)
focal_class.return: boolean
focal_class.signature: boolean equals(Object obj)
focal_class.class_method_signature: TimeFrameImpl.toString()
focal_class.full_signature: public String toString()
focal_class.identifier: toString
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_method.body: @Override
  	public boolean isDerivableFrom(TimeFrame tf) {
  		TimeFrameImpl other = (TimeFrameImpl)tf;
  		boolean retVal = false;
  		
  		PeriodType otherType = other.getPeriod().getPeriodType();
  		PeriodType thisType = period.getPeriodType();
          int otherDuration = other.getPeriod().size();
          int thisDuration = getPeriod().size();
          
  		if(equals(other)) {
  			retVal = true;
  		}else{
  		    if(((otherType == thisType && otherType != PeriodType.WEEK && (otherDuration == thisDuration || (thisDuration % otherDuration == 0 && other.startDate.isEqual(startDate) && areEqualOrNull(other.endDate, endDate)))) || 
  		        (otherType.isLowerThan(thisType) && otherType != PeriodType.WEEK  && otherDuration == 1))) {
  		        retVal = true;
              }
      		
  		    //Use the highest resolution type to create comparison resolution instances.
  		    //(i.e. July being > May is more significant than 4:30 > 2:00)
  		    PeriodType resolutionDeterminer = otherType.isLowerThan(thisType) ? thisType : otherType;
      		if(resolutionDeterminer.resolutionInstant(other.startDate).isAfter(resolutionDeterminer.resolutionInstant(startDate))) {
      			retVal = false;
      		}
      		
      		if((other.endDate != null && endDate == null) || ((other.endDate != null && endDate != null) && 
      		    resolutionDeterminer.resolutionInstant(other.endDate).isAfter(resolutionDeterminer.resolutionInstant(endDate)))) {
      		    retVal = false;
      		}
  		}
  		
  		return retVal;
  	}
focal_method.class_method_signature: TimeFrameImpl.isDerivableFrom(TimeFrame tf)
focal_method.full_signature: @Override public boolean isDerivableFrom(TimeFrame tf)
focal_method.identifier: isDerivableFrom
focal_method.invocations: getPeriodType getPeriod getPeriodType size getPeriod size getPeriod equals isEqual areEqualOrNull isLowerThan isLowerThan isAfter resolutionInstant resolutionInstant isAfter resolutionInstant resolutionInstant
focal_method.modifiers: @Override public
focal_method.parameters: (TimeFrame tf)
focal_method.return: boolean
focal_method.signature: boolean isDerivableFrom(TimeFrame tf)