Enum ChecksumType

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ChecksumType>

    public enum ChecksumType
    extends java.lang.Enum<ChecksumType>
    Author:
    Yoav Landman
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      md5  
      sha1  
      sha256  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String alg()  
      java.lang.String ext()  
      static ChecksumType forAlgorithm​(java.lang.String algorithm)  
      static ChecksumType forFilePath​(java.lang.String filePath)  
      boolean isValid​(java.lang.String candidate)  
      int length()  
      java.lang.String toString()  
      static ChecksumType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ChecksumType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • BASE_CHECKSUM_TYPES

        public static final java.util.List<ChecksumType> BASE_CHECKSUM_TYPES
    • Method Detail

      • values

        public static ChecksumType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (ChecksumType c : ChecksumType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ChecksumType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • alg

        public java.lang.String alg()
      • ext

        public java.lang.String ext()
        Returns:
        The filename extension of the checksum, including the dot prefix.
      • length

        public int length()
        Returns:
        The length of a valid checksum for this checksum type.
      • isValid

        public boolean isValid​(java.lang.String candidate)
        Parameters:
        candidate - Checksum candidate
        Returns:
        True if this string is a checksum value for this type
      • forFilePath

        public static ChecksumType forFilePath​(java.lang.String filePath)
        Parameters:
        filePath - The checksum file path (assumed to end with the checksum extension).
        Returns:
        Checksum type for the given file path. Null if not found.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Enum<ChecksumType>
      • forAlgorithm

        public static ChecksumType forAlgorithm​(java.lang.String algorithm)