      - returns: Minimal satisfying count of characters inside the text field.
      */
     public func acceptableTextLength() -> Int {
-        var state: State? = self.initialState
-        var length: Int = 0
-        while let s: State = state, !(state is EOLState) {
-            if s is FixedState || s is FreeState || s is ValueState {
-                length += 1
-            }
-            state = s.child
-        }
-        
-        return length
+        return self.countStates(ofTypes: [FixedState.self, FreeState.self, ValueState.self])
     }
     
     /**

     - returns: Total available count of mandatory and optional characters inside the text field.
     */
    public func totalTextLength() -> Int {
        var state: State? = self.initialState
        var length: Int = 0
        while let s: State = state, !(state is EOLState) {
            if s is FixedState || s is FreeState || s is ValueState || s is OptionalValueState {
                length += 1
            }
            state = s.child
        }
        
        return length
    }
    
    /**

    }
    
}


private extension Mask {
    
    func countStates(ofTypes stateTypes: [State.Type]) -> Int {
        var state: State? = self.initialState
        var length: Int = 0
        while let s: State = state, !(state is EOLState) {
            for stateType in stateTypes {
                if type(of: s) == stateType {
                    length += 1
                }
            }
            state = s.child
        }
        
        return length
    }
    
}
