@@ -301,12 +301,16 @@ public String getAndPrint(E object) {
301
301
public abstract boolean allowothervalues ();
302
302
303
303
/**
304
+ * @param current the current value
304
305
* @return the value to consolidate other values in. Example, if you want to
305
306
* have always time data from a 5 years time window, you may have a
306
307
* value 'Before' that will consolidate values from previous year when
307
- * you get previous year data
308
+ * you get previous year data. Return null in order not to consolidate
309
+ * the data
310
+ * @since 1.11.4
308
311
*/
309
- public abstract F getDefaultValueForOtherData ();
312
+
313
+ public abstract F getDefaultValueForOtherData (F current );
310
314
311
315
/**
312
316
* This method checks if the current value can be kept or an alternative should
@@ -348,7 +352,7 @@ public boolean replaceWithDefaultValue(E object) {
348
352
}
349
353
350
354
}
351
- F alternative = getDefaultValueForOtherData ();
355
+ F alternative = getDefaultValueForOtherData (get ( object ) );
352
356
if (alternative != null ) {
353
357
logger .finer (" ---> Found alternative " + alternative );
354
358
set (object , alternative );
@@ -592,15 +596,18 @@ public boolean isValid(E optionalorinvalid) {
592
596
if (this .allowothervalues ())
593
597
return true ;
594
598
F value = getter .apply (optionalorinvalid );
595
- if (value ==null ) return false ;
599
+ if (value == null )
600
+ return false ;
596
601
F [] mandatoryvalues = this .getMandatoryValues ();
597
602
F [] optionalvalues = this .getOptionalValues ();
598
- if (mandatoryvalues !=null ) for (int i = 0 ; i < mandatoryvalues .length ; i ++)
599
- if (value .equals (mandatoryvalues [i ]))
600
- return true ;
601
- if (optionalvalues !=null ) for (int i = 0 ; i < optionalvalues .length ; i ++)
602
- if (value .equals (optionalvalues [i ]))
603
- return true ;
603
+ if (mandatoryvalues != null )
604
+ for (int i = 0 ; i < mandatoryvalues .length ; i ++)
605
+ if (value .equals (mandatoryvalues [i ]))
606
+ return true ;
607
+ if (optionalvalues != null )
608
+ for (int i = 0 ; i < optionalvalues .length ; i ++)
609
+ if (value .equals (optionalvalues [i ]))
610
+ return true ;
604
611
return false ;
605
612
}
606
613
@@ -613,12 +620,14 @@ public boolean isTextValid(
613
620
return true ;
614
621
F [] mandatoryvalues = this .getMandatoryValues ();
615
622
F [] optionalvalues = this .getOptionalValues ();
616
- if (mandatoryvalues !=null ) for (int i = 0 ; i < mandatoryvalues .length ; i ++)
617
- if (payload .equals (mandatoryvalues [i ]))
618
- return true ;
619
- if (optionalvalues !=null ) for (int i = 0 ; i < optionalvalues .length ; i ++)
620
- if (payload .equals (optionalvalues [i ]))
621
- return true ;
623
+ if (mandatoryvalues != null )
624
+ for (int i = 0 ; i < mandatoryvalues .length ; i ++)
625
+ if (payload .equals (mandatoryvalues [i ]))
626
+ return true ;
627
+ if (optionalvalues != null )
628
+ for (int i = 0 ; i < optionalvalues .length ; i ++)
629
+ if (payload .equals (optionalvalues [i ]))
630
+ return true ;
622
631
return false ;
623
632
}
624
633
0 commit comments