/* * [SocketType.java] * * Summary: enum constants for CPU socket types. * * 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 CPU socket types. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-02-20 initial version. * @since 2011-02-20 */ public enum SocketType { // AMD sockets, fastest at top. Need research to sort AM3( "AMD AM3", "AM3" ), AM2PLUS( "AMD AM2+", "AM2+" ), AM2( "AMD AM2", "AM2" ), AMBGA( "AMD BGA FT1" ), AMA( "AMD A", "A" ), AM939( "AMD 939", "939" ), AM754( "AMD 754", "754" ), // Intel sockets, fastest at top I1366( "Intel 1366", "1366", "Intel Socket 1366" ), I1155( "Intel 1155", "1155" ), I1156( "Intel 1156", "1156" ), I775( "Intel 775", "775" ), I559( "Intel 559", "559", "Intel BGA 559", "Intel Atom D" ), I479( "Intel 479", "479" ), I478( "Intel 478", "478" ), I437( "Intel 437", "437", "Intel Atom", "Atom" ), IM( "Intel IM", "IM" ), I423( "Intel 423", "423" ), I370( "Intel 370", "370" ), UNKNOWN( "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 */ SocketType( 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 SocketType 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 ( SocketType candidateEnum : SocketType.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 SocketType: " + 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(); } } }