java - Check enum for multiple values -


i have enum filetype

public static enum filetype {   csv, xml, xls, txt, fixed_length }  filetype filetype = filetype.csv; 

is there better (cleaner) way check filetype multiple values following (like "mystring".matches("a|b|c");)?

if(filetype == filetype.csv || filetype == filetype.txt || filetype == filetype.fixed_length) {} 

why not use switch:

switch(filetype) {    case csv:    case txt:    case fixed_length:        dosomething();        break; } 

this same if statement check, it's more readable, imho.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -