001/** 002 * Copyright (c) 2014 Digi International Inc., 003 * All rights not expressly granted are reserved. 004 * 005 * This Source Code Form is subject to the terms of the Mozilla Public 006 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 007 * You can obtain one at http://mozilla.org/MPL/2.0/. 008 * 009 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343 010 * ======================================================================= 011 */ 012package com.digi.xbee.api.models; 013 014import java.util.HashMap; 015 016/** 017 * Enumerates several AT commands used to parse AT command packets. The list 018 * of AT Command alias listed here represents those AT commands whose values 019 * should be parsed as strings. 020 */ 021public enum ATStringCommands { 022 023 NI("NI"), 024 KY("KY"), 025 NK("NK"), 026 ZU("ZU"), 027 ZV("ZV"), 028 CC("CC"); 029 030 // Variables 031 private final static HashMap<String, ATStringCommands> lookupTable = new HashMap<String, ATStringCommands>(); 032 033 static { 034 for (ATStringCommands atStringCommand:values()) 035 lookupTable.put(atStringCommand.getCommand(), atStringCommand); 036 } 037 038 private final String command; 039 040 /** 041 * Class constructor. Instantiates a new enumeration element of type 042 * {@code ATStringCommands} with the given AT Command alias. 043 * 044 * @param command The AT Command alias. 045 */ 046 private ATStringCommands(String command) { 047 this.command = command; 048 } 049 050 /** 051 * Returns the AT Command alias. 052 * 053 * @return The AT Command alias. 054 */ 055 public String getCommand() { 056 return command; 057 } 058 059 /** 060 * Returns the {@code ATStringCommands} for the given AT Command alias. 061 * 062 * @param command The AT Command alias to retrieve the corresponding 063 * {@code ATStringCommands}. 064 * 065 * @return The {@code ATStringCommands} associated to the given AT Command 066 * alias. 067 */ 068 public static ATStringCommands get(String command) { 069 return lookupTable.get(command.toUpperCase()); 070 } 071}