aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/common/library/item/LibraryItemProperty.java
blob: 2e4d2efb5d503ccaba5471e5e3cd5d0069a75356 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package uk.org.ury.common.library.item;

/**
 * The parameters that are stored in the LibraryItem.
 * 
 * @author  Matt Windsor
 */

public enum LibraryItemProperty
  {
    // Constant     SQL identifier       
    TITLE           ("title"),
    ALBUM           ("album"),
    ARTIST          ("artist"),
    LABEL           ("label"),
    STATUS          ("status"),
    MEDIUM          ("medium"),
    FORMAT          ("format"),
    DATE_RELEASED   ("datereleased"),
    DATE_ADDED      ("dateadded"),
    DATE_EDITED     ("dateedited"),
    SHELF_LETTER    ("shelfletter"),
    SHELF_NUMBER    ("shelfnumber"),
    CD_ID           ("cdid"),
    IS_DIGITISED    ("digitised"),
    IS_CLEAN        ("clean");
    
    
    public final String sql;
    
    
    private
    LibraryItemProperty (String sql)
    {
      this.sql = sql;
    }


    /**
     * Retrieve a LibraryItemProperty given its SQL identifier.
     * 
     * @param string  The SQL identifier.
     * @return        The first property to match.
     * 
     * @throws        IllegalArgumentException if no matches were
     *                found.
     */
    
    public static LibraryItemProperty
    getFromSQL (String string)
    {
      // TODO: Better exception?
      
      for (LibraryItemProperty prop : values ())
        {
          if (prop.sql.equals (string))
            return prop;
        }
      
      throw new IllegalArgumentException ("Nonexistent property SQL.");
    }
  };