Java to Beanshell: validate an attribute for each record of a spreadsheet Suppose this Java code is converted to Beanshell and called by an application which reads a spreadsheet and validates the department of each employee at a university.  

My primary concern is if there is a more efficient, standard, or otherwise better way to go about validating an employee's department rather than how I have done so below.  Null should be returned if the department is invalid.

import java.util.HashSet;
import java.util.Arrays;

public class Test{

    public static final String VALID_DEPARTMENTS[] = {
            "Computer Science", "Biology"
    };

    public static final HashSet&lt;String&gt; set = new HashSet&lt;String&gt;( Arrays.asList(VALID_DEPARTMENTS) );

    public String validate(String dep) {
        if( set.contains(dep) )
            return dep; 
        return null;
    }

    public static void main(String[] args){
        Test t = new Test();
        System.out.println( t.validate("CS") );
    }
}
A few things come to mind:


In Java 9 one can use Set.of("X", "Y", ...).
Or could simplify to private static final Set&lt;String&gt; VALID_DEPARTMENTS = new HashSet&lt;&gt;(Arrays.asList("A", "B"));
Could modify validate(dep) to return set.contains(dep) ? dep : null;
It would be nice to return "" instead of null if at all possible.  This is so that a project won't end up with tons of if (x != null) all over the place.
Recommend renaming Test to something more descriptive.  Maybe DepartmentValidator might be a step in the right direction.
Probably refactor dep to department.  Eventually the meaning may become less obvious as time passes and the code base grows larger.
Note: the validation is currently quite strict (exact match), so I'm assuming the incoming data is pretty exact (no misspellings or different capitalization, etc.)