Coverage Report - org.vostokframework.domain.assets.AssetType
 
Classes in this File Line Coverage Branch Coverage Complexity
AssetType
95%
20/21
N/A
0
 
 1  
 /*
 2  
  * Licensed under the MIT License
 3  
  * 
 4  
  * Copyright 2011 (c) Flávio Silva, flsilva.com
 5  
  *
 6  
  * Permission is hereby granted, free of charge, to any person
 7  
  * obtaining a copy of this software and associated documentation
 8  
  * files (the "Software"), to deal in the Software without
 9  
  * restriction, including without limitation the rights to use,
 10  
  * copy, modify, merge, publish, distribute, sublicense, and/or sell
 11  
  * copies of the Software, and to permit persons to whom the
 12  
  * Software is furnished to do so, subject to the following
 13  
  * conditions:
 14  
  *
 15  
  * The above copyright notice and this permission notice shall be
 16  
  * included in all copies or substantial portions of the Software.
 17  
  *
 18  
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 19  
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 20  
  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 21  
  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22  
  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 23  
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 24  
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 25  
  * OTHER DEALINGS IN THE SOFTWARE.
 26  
  * 
 27  
  * http://www.opensource.org/licenses/mit-license.php
 28  
  */
 29  1
 package org.vostokframework.domain.assets
 30  
 {
 31  
         import org.as3collections.IIterator;
 32  
         import org.as3collections.lists.ArrayList;
 33  
         import org.as3collections.utils.ListUtil;
 34  
         import org.as3collections.IList;
 35  
         import org.as3coreaddendum.system.Enum;
 36  
         import org.as3utils.StringUtil;
 37  
 
 38  
         import flash.errors.IllegalOperationError;
 39  
 
 40  
         /**
 41  
          * description
 42  
          * 
 43  
          * @author Flávio Silva
 44  
          */
 45  
         public class AssetType extends Enum
 46  
         {
 47  
                 public static const AAC:AssetType = new AssetType("AAC", 0);
 48  
                 public static const CSS:AssetType = new AssetType("CSS", 1);
 49  
                 public static const IMAGE:AssetType = new AssetType("IMAGE", 2);
 50  
                 public static const JSON:AssetType = new AssetType("JSON", 3);
 51  
                 public static const MP3:AssetType = new AssetType("MP3", 4);
 52  
                 public static const SWF:AssetType = new AssetType("SWF", 5);
 53  
                 public static const TXT:AssetType = new AssetType("TXT", 6);
 54  
                 public static const VIDEO:AssetType = new AssetType("VIDEO", 7);
 55  
                 public static const XML:AssetType = new AssetType("XML", 8);
 56  
                 
 57  
                 /**
 58  
                  * @private
 59  
                  */
 60  
                 private static var _created :Boolean = false;
 61  
                 
 62  
                 {
 63  
                         _created = true;
 64  
                 }
 65  
                 
 66  
                 public function AssetType(name:String, ordinal:int)
 67  
                 {
 68  1
                         super(name, ordinal);
 69  1
                         if (_created) throw new IllegalOperationError("The set of acceptable values by this Enumerated Type has already been created internally.");
 70  1
                 }
 71  
                 
 72  
                 public static function getByName(name:String):AssetType
 73  
                 {
 74  1
                         if (StringUtil.isBlank(name)) throw new ArgumentError("Argument <name> must not be null nor an empty String.");
 75  
                         
 76  1
                         var it:IIterator = getTypes().iterator();
 77  
                         var type:AssetType;
 78  
                         
 79  1
                         while (it.hasNext())
 80  
                         {
 81  1
                                 type = it.next();
 82  1
                                 if (type.name == name.toUpperCase()) return type;
 83  
                         }
 84  
                         
 85  0
                         throw new ArgumentError("There is no AssetType object with <name>: " + name);
 86  
                 }
 87  
                 
 88  
                 public static function getTypes():IList
 89  
                 {
 90  1
                         var types:IList = ListUtil.getUniqueTypedList(new ArrayList(), AssetType);
 91  1
                         types.add(AAC);
 92  1
                         types.add(CSS);
 93  1
                         types.add(IMAGE);
 94  1
                         types.add(JSON);
 95  1
                         types.add(MP3);
 96  1
                         types.add(SWF);
 97  1
                         types.add(TXT);
 98  1
                         types.add(VIDEO);
 99  1
                         types.add(XML);
 100  
                         
 101  1
                         return types;
 102  
                 }
 103  
 
 104  
         }
 105  
 
 106  
 }