001/** 002 * Copyright 2017, Digi International Inc. 003 * 004 * This Source Code Form is subject to the terms of the Mozilla Public 005 * License, v. 2.0. If a copy of the MPL was not distributed with this 006 * file, you can obtain one at http://mozilla.org/MPL/2.0/. 007 * 008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 015 */ 016package com.digi.xbee.api.models; 017 018import java.util.HashMap; 019 020/** 021 * Enumerates several AT commands used to parse AT command packets. The list 022 * of AT Command alias listed here represents those AT commands whose values 023 * should be parsed as strings. 024 */ 025public enum ATStringCommands { 026 027 NI("NI"), 028 KY("KY"), 029 NK("NK"), 030 ZU("ZU"), 031 ZV("ZV"), 032 CC("CC"); 033 034 // Variables 035 private final static HashMap<String, ATStringCommands> lookupTable = new HashMap<String, ATStringCommands>(); 036 037 static { 038 for (ATStringCommands atStringCommand:values()) 039 lookupTable.put(atStringCommand.getCommand(), atStringCommand); 040 } 041 042 private final String command; 043 044 /** 045 * Class constructor. Instantiates a new enumeration element of type 046 * {@code ATStringCommands} with the given AT Command alias. 047 * 048 * @param command The AT Command alias. 049 */ 050 private ATStringCommands(String command) { 051 this.command = command; 052 } 053 054 /** 055 * Returns the AT Command alias. 056 * 057 * @return The AT Command alias. 058 */ 059 public String getCommand() { 060 return command; 061 } 062 063 /** 064 * Returns the {@code ATStringCommands} for the given AT Command alias. 065 * 066 * @param command The AT Command alias to retrieve the corresponding 067 * {@code ATStringCommands}. 068 * 069 * @return The {@code ATStringCommands} associated to the given AT Command 070 * alias. 071 */ 072 public static ATStringCommands get(String command) { 073 return lookupTable.get(command.toUpperCase()); 074 } 075}