class HddInfoHelper {

    public static boolean isSmartDataBeyondThreshold( HddSMARTData hddSMARTData,
                                                      boolean isValueGreaterThanThresholdConcerning )
    {
        boolean isDataConcerning = false;

        if ( hddSMARTData != null )
        {
            String thresholdString = hddSMARTData.getThreshold();
            String valueString = hddSMARTData.getValue();

            if ( valueString != null )
            {
                if ( thresholdString != null )
                {
                    Integer value = null;
                    Integer threshold = null;

                    try
                    {
                        value = Integer.parseInt( valueString );
                        threshold = Integer.parseInt( thresholdString );
                    }
                    catch ( Exception e )
                    {
                        return false;
                    }

                    // Check if value lower than threshold is concerning or the opposite of it.
                    // If isValueLowerTheBetter is true,
                    // it means that if value exceeds the defined threshold, the data is concerning.
                    if ( isValueGreaterThanThresholdConcerning )
                    {
                        if ( value >= threshold && threshold != 0 )
                        {
                            isDataConcerning = true;
                        }
                    }
                    else
                    {
                        // threshold 0 means that the attribute the threshold is associated to should be considered only
                        // informational
                        // and that it has no direct influence over reliability
                        // If the threshold was set by the device manufacturer to 0, it means this is an informational
                        // attribute.
                        // Please refer: http://www.almico.com/sfarticle.php?id=2
                        if ( value <= threshold && threshold != 0 )
                        {
                            isDataConcerning = true;
                        }
                    }
                }
            }
        }

        return isDataConcerning;
    }

}