/* * [FormFactor.java] * * Summary: enum constants for motherboard form factors. * * Copyright: (c) 2011-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.7+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2011-02-20 initial version. */ package com.mindprod.mother; /** * enum constants for motherboard form factors. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-02-20 initial version. * @since 2011-02-20 */ public enum FormFactor { // small to big, sorted by area MINI_ITX( "Mini-ITX", "mini ITX" ), // 17.0 x 17.0 MINI_DTX( "Mini-DTX", "mini DTX" ), // 20.3 x 17.0 TAILLE( "Taille Micro-ATX" ), // 24.4 x 17.0 DTX(), // 20.3 x 24.4 PICO_BTX( "Pico-BTX", "pico BTX" ), // 26.7 x 20.3 MICRO_ATX( "Micro-ATX", "micro ATX", "MicroATX", "MIRCO ATX", "MATX" ), // 24.4 24.4 MICRO_BTX( "Micro-BTX", "micro BTX" ),// 26.4 x 26.7 BABY_AT( "Baby-AT", "baby AT" ),// 33.0 x 21.6 ATX(), // 30.5 x 24.4 BTX(), // 32.5 x 26.6 XL( "XL-ATX", "Ultra-ATX" ), // 34.3 x 26.2 AT(), // 35.0 x 30.5 WTX( "WTX", " Workstation ATX", "WATX" ), // 35.6 x 42.5 UNKNOWN(); /** * cannot use String... here, only in parm list alternate input names for the alias */ private final String[] aliases; /** * constructor for an enum constant * * @param aliases other names for string input */ FormFactor( String... aliases ) { this.aliases = aliases; } /** * convert alias string to equivalent canonical enum constant, like valueOf but accepts aliases too, and does not * care about case. * * @param s alias as string * * @return equivalent AppCat enum constant */ public static FormFactor valueOfAlias( String s ) { s = s.trim(); try { return valueOf( s.toUpperCase() ); } catch ( IllegalArgumentException e ) { // usual method failed, try looking up alias // This seems long winded, why no HashSet? // Because Java won't let me access a static common // lookup in the enum constructors. for ( FormFactor candidateEnum : FormFactor.values() ) { for ( String candidateString : candidateEnum.aliases ) { if ( candidateString.equalsIgnoreCase( s ) ) { return candidateEnum; } } } // fell out the bottom of search over all enums and aliases // give up throw new IllegalArgumentException( "unknown FormFactor: " + s ); } } /** * ordinary toString * * @return upper and lower case name for the manufacturer. */ public String toString() { if ( aliases.length > 0 ) { return aliases[ 0 ]; } else { return name(); } } }