ConnectionType.java :  » Java-3D » openwonderland » org » jdesktop » wonderland » common » comms » Java Open Source

Java Open Source » Java 3D » openwonderland 
openwonderland » org » jdesktop » wonderland » common » comms » ConnectionType.java
/**
 * Project Wonderland
 *
 * Copyright (c) 2004-2009, Sun Microsystems, Inc., All Rights Reserved
 *
 * Redistributions in source code form must reproduce the above
 * copyright and this condition.
 *
 * The contents of this file are subject to the GNU General Public
 * License, Version 2 (the "License"); you may not use this file
 * except in compliance with the License. A copy of the License is
 * available at http://www.opensource.org/licenses/gpl-license.php.
 *
 * Sun designates this particular file as subject to the "Classpath" 
 * exception as provided by Sun in the License file that accompanied 
 * this code.
 */
package org.jdesktop.wonderland.common.comms;

import java.io.Serializable;
import org.jdesktop.wonderland.common.ExperimentalAPI;

/**
 * The type of a Wonderland connection.
 * @author jkaplan
 */
@ExperimentalAPI
public class ConnectionType implements Serializable {
    private String type;
    
    /**
     * Create a new client type with the given type name
     * @param type the name of the type
     */
    public ConnectionType(String type) {
        this.type = type;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        
        // all client types are comparable to each other
        if (!(obj instanceof ConnectionType)) {
            return false;
        }
        
        final ConnectionType other = (ConnectionType) obj;
        if (this.type != other.type && 
                (this.type == null || !this.type.equals(other.type)))
        {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (this.type != null ? this.type.hashCode() : 0);
        return hash;
    }
    
    @Override
    public String toString() {
        return type;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.