/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

====================================================================== */

package org.bodington.server.userimport.oucsir;

import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * List of statuses that registration hold. At the moment each user can only have one
 * status and it's just chance as to which one they get!
 * @author buckett
 */
class OUCSStatus implements Map.Entry
{
    
    /**
     * Very simple map based around a set of Map.Entry items.
     * @author buckett
     */
    private static class SetMap extends AbstractMap
    {
        public Set set = new HashSet();
        public Set entrySet()
        {
            return set;
        }
    }
    
    private static final SetMap statuses = new OUCSStatus.SetMap();

    /**
     * Cardholder without Library access. Doesn't have WebAuth username.
     */
    public static final OUCSStatus CARDHOLDER = new OUCSStatus("cardholder", false);
    /**
     * College Staff.
     */
    public static final OUCSStatus COLLEGE = new OUCSStatus("college", true);
    /**
     * Department staff.
     */
    public static final OUCSStatus DEPT = new OUCSStatus("dept", true);
    /**
     * Postgraduate student.
     */
    public static final OUCSStatus POSTGRAD = new OUCSStatus("postgrad", true);
    /**
     * Retired members of staff. Have WebAuth account.
     */
    public static final OUCSStatus RET = new OUCSStatus("ret", true);
    /**
     * Senior member of staff.
     */
    public static final OUCSStatus SENMEM = new OUCSStatus("senmem", true);
    /**
     * Staff member.
     */
    public static final OUCSStatus STAFF = new OUCSStatus("staff", true);
    /**
     * Student. Normally visiting from other institution.
     */
    public static final OUCSStatus STUDENT = new OUCSStatus("student", true);
    /**
     * Normal Oxford undergraduate student.
     */
    public static final OUCSStatus UNDERGRAD = new OUCSStatus("undergrad", true);
    /**
     * Visiting academic. Gets WebAuth account.
     */
    public static final OUCSStatus VISITOR = new OUCSStatus("visitor", true);
    /**
     * Virtual Card holder. Gets WebAuth account.
     */
    public static final OUCSStatus VIRTUAL = new OUCSStatus("virtual", true);
    
    

    
    public static Map getStatuses()
    {
        return statuses;
    }

    
    private String status;
    private boolean webauth;
    
    private OUCSStatus( String status, boolean webauth )
    {
        this.status = status;
        this.webauth = webauth;
        statuses.set.add(this);
    }
    
    public String getStatus()
    {
        return status;
    }
    
    public boolean isWebauth()
    {
        return webauth;
    }

    public Object getKey()
    {
            return status;
    }

    public Object getValue()
    {
            return this;
    }

    public Object setValue( Object arg0 )
    {
        throw new UnsupportedOperationException();
    }
}
