MAConfig implements XmlConvertible { public static boolean isMaxTimeDifferenceValid(String maxTimeDifference) { if (maxTimeDifference == null || maxTimeDifference.trim().isEmpty()) { return true; } maxTimeDifference = maxTimeDifference.trim(); if (maxTimeDifference.endsWith("d") && maxTimeDifference.length() >= 2) { String daysAsString = maxTimeDifference.substring(0, maxTimeDifference.length() - 1); try { int days = Integer.parseInt(daysAsString); return days >= 0; } catch (NumberFormatException nfe) { return false; } } else { try { return Double.parseDouble(maxTimeDifference) >= 0; } catch (NumberFormatException nfe) { return false; } } } MAConfig(); static MAConfig get(Configuration conf); static MAConfig fromXml(String xml); @Override String toXml(); RecordSource createRecordSource(Configuration conf); String getRecordSourceSpiClassName(); void setRecordSourceSpiClassName(String recordSourceSpiClassName); String getRecordSourceUrl(); void setRecordSourceUrl(String recordSourceUrl); String getOutputTimeFormat(); void setOutputTimeFormat(String outputTimeFormat); String getOutputGroupName(); void setOutputGroupName(String outputGroupName); boolean getCopyInput(); void setCopyInput(boolean copyInput); int getMacroPixelSize(); void setMacroPixelSize(int macroPixelSize); String getMaxTimeDifference(); void setMaxTimeDifference(String maxTimeDifference); Double getFilteredMeanCoeff(); void setFilteredMeanCoeff(Double filteredMeanCoeff); String getGoodPixelExpression(); void setGoodPixelExpression(String goodPixelExpression); String getGoodRecordExpression(); void setGoodRecordExpression(String goodRecordExpression); boolean getFilterOverlapping(); void setFilterOverlapping(boolean filterOverlapping); boolean getSaveProcessedProducts(); void setSaveProcessedProducts(boolean saveProcessedProducts); VariableMapping[] getVariableMappings(); void setVariableMappings(VariableMapping[] variableMappings); boolean getOnlyExtractComplete(); void setOnlyExtractComplete(boolean onlyExtractComplete); static boolean isMaxTimeDifferenceValid(String maxTimeDifference);  }
@Test public void testIsMaxTimeDifferenceValid() throws Exception { assertTrue(MAConfig.isMaxTimeDifferenceValid(null)); assertTrue(MAConfig.isMaxTimeDifferenceValid("")); assertTrue(MAConfig.isMaxTimeDifferenceValid(" ")); assertTrue(MAConfig.isMaxTimeDifferenceValid("0")); assertTrue(MAConfig.isMaxTimeDifferenceValid("0.0")); assertTrue(MAConfig.isMaxTimeDifferenceValid("1")); assertTrue(MAConfig.isMaxTimeDifferenceValid("1.2")); assertTrue(MAConfig.isMaxTimeDifferenceValid(" 1.2 ")); assertTrue(MAConfig.isMaxTimeDifferenceValid("-0")); assertTrue(MAConfig.isMaxTimeDifferenceValid("0d")); assertTrue(MAConfig.isMaxTimeDifferenceValid("1d")); assertTrue(MAConfig.isMaxTimeDifferenceValid("2d")); assertFalse(MAConfig.isMaxTimeDifferenceValid("0.0d")); assertFalse(MAConfig.isMaxTimeDifferenceValid("-1d")); assertFalse(MAConfig.isMaxTimeDifferenceValid("-1")); assertFalse(MAConfig.isMaxTimeDifferenceValid("-2")); assertFalse(MAConfig.isMaxTimeDifferenceValid("1w")); }