Class SafeNumberOperationUtils


  • public final class SafeNumberOperationUtils
    extends Object
    Safe number operation utility class.
    • Constructor Detail

      • SafeNumberOperationUtils

        public SafeNumberOperationUtils()
    • Method Detail

      • safeIntersection

        public static com.google.common.collect.Range<Comparable<?>> safeIntersection​(com.google.common.collect.Range<Comparable<?>> range,
                                                                                      com.google.common.collect.Range<Comparable<?>> connectedRange)
        Execute range intersection method by safe mode.
        Parameters:
        range - range
        connectedRange - connected range
        Returns:
        the intersection result of two ranges
      • safeClosed

        public static com.google.common.collect.Range<Comparable<?>> safeClosed​(Comparable<?> lowerEndpoint,
                                                                                Comparable<?> upperEndpoint)
        Execute range closed method by safe mode.
        Parameters:
        lowerEndpoint - lower endpoint
        upperEndpoint - upper endpoint
        Returns:
        new range
      • safeContains

        public static boolean safeContains​(com.google.common.collect.Range<Comparable<?>> range,
                                           Comparable<?> endpoint)
        Execute range contains method by safe mode.
        Parameters:
        range - range
        endpoint - endpoint
        Returns:
        whether the endpoint is included in the range
      • safeRangeEquals

        public static boolean safeRangeEquals​(com.google.common.collect.Range<Comparable<?>> sourceRange,
                                              com.google.common.collect.Range<Comparable<?>> targetRange)
        Execute range equals method by safe mode.
        Parameters:
        sourceRange - source range
        targetRange - target range
        Returns:
        whether the source range and target range are same
      • safeCollectionEquals

        public static boolean safeCollectionEquals​(Collection<Comparable<?>> sources,
                                                   Collection<Comparable<?>> targets)
        Execute collection equals method by safe mode.
        Parameters:
        sources - source collection
        targets - target collection
        Returns:
        whether the element in source collection and target collection are all same