import Exception from './../../Exception' ; export const enum ErrorCorrectionLevelValues { L , M , Q , H } author Sean Owen
  export default class ErrorCorrectionLevel { private static FOR_BITS = new Map < number , ErrorCorrectionLevel > ( ) ; private static FOR_VALUE = new Map < ErrorCorrectionLevelValues , ErrorCorrectionLevel > ( ) ; /** L = ~7% correction */ public static L = new ErrorCorrectionLevel ( ErrorCorrectionLevelValues . L , "L" , 0x01 ) ; /** M = ~15% correction */ public static M = new ErrorCorrectionLevel ( ErrorCorrectionLevelValues . M , "M" , 0x00 ) ; /** Q = ~25% correction */ public static Q = new ErrorCorrectionLevel ( ErrorCorrectionLevelValues . Q , "Q" , 0x03 ) ; /** H = ~30% correction */ public static H = new ErrorCorrectionLevel ( ErrorCorrectionLevelValues . H , "H" , 0x02 ) ; private constructor ( private value , private stringValue , private bits ) { ErrorCorrectionLevel . FOR_BITS . set ( bits , this ) ; ErrorCorrectionLevel . FOR_VALUE . set ( value , this ) ; } public getValue ( ) { return this . value ; } public getBits ( ) { return this . bits ; } public static fromString ( s ) { switch ( s ) { case "L" : return ErrorCorrectionLevel . L ; case "M" : return ErrorCorrectionLevel . M ; case "Q" : return ErrorCorrectionLevel . Q ; case "H" : return ErrorCorrectionLevel . H ; default : throw new Exception ( Exception . ArgumentException , s + "not available" ) ; } } public toString ( ) { return this . stringValue ; } public equals ( o ) { if ( ! ( o instanceof ErrorCorrectionLevel ) ) { return false ; } const other = < ErrorCorrectionLevel > o ; return this . value === other . value ; } param bits return public static forBits ( bits ) { if ( bits < 0 || bits >= ErrorCorrectionLevel . FOR_BITS . size ) { throw new Exception ( Exception . IllegalArgumentException ) ; } return ErrorCorrectionLevel . FOR_BITS . get ( bits ) ; } }