001    /*
002     * Copyright (c) 2007-2014 Concurrent, Inc. All Rights Reserved.
003     *
004     * Project and contact information: http://www.cascading.org/
005     *
006     * This file is part of the Cascading project.
007     *
008     * Licensed under the Apache License, Version 2.0 (the "License");
009     * you may not use this file except in compliance with the License.
010     * You may obtain a copy of the License at
011     *
012     *     http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing, software
015     * distributed under the License is distributed on an "AS IS" BASIS,
016     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017     * See the License for the specific language governing permissions and
018     * limitations under the License.
019     */
020    
021    package cascading.flow.planner;
022    
023    import java.io.Serializable;
024    
025    /**
026     *
027     */
028    public class PlatformInfo implements Serializable, Comparable
029      {
030      public final String name;
031      public final String vendor;
032      public final String version;
033    
034      public PlatformInfo( String name, String vendor, String version )
035        {
036        this.name = name;
037        this.vendor = vendor;
038        this.version = version;
039        }
040    
041      @Override
042      public boolean equals( Object object )
043        {
044        if( this == object )
045          return true;
046        if( object == null || getClass() != object.getClass() )
047          return false;
048    
049        PlatformInfo that = (PlatformInfo) object;
050    
051        if( name != null ? !name.equals( that.name ) : that.name != null )
052          return false;
053        if( vendor != null ? !vendor.equals( that.vendor ) : that.vendor != null )
054          return false;
055        if( version != null ? !version.equals( that.version ) : that.version != null )
056          return false;
057    
058        return true;
059        }
060    
061      @Override
062      public int compareTo( Object o )
063        {
064        if( name == null )
065          return -1;
066    
067        return name.compareTo( ( (PlatformInfo) o ).name );
068        }
069    
070      @Override
071      public int hashCode()
072        {
073        int result = name != null ? name.hashCode() : 0;
074        result = 31 * result + ( vendor != null ? vendor.hashCode() : 0 );
075        result = 31 * result + ( version != null ? version.hashCode() : 0 );
076        return result;
077        }
078    
079      @Override
080      public String toString()
081        {
082        final StringBuilder sb = new StringBuilder();
083    
084        sb.append( name ).append( ':' );
085    
086        if( version != null )
087          sb.append( version ).append( ':' );
088    
089        if( vendor != null )
090          sb.append( vendor );
091    
092        return sb.toString();
093        }
094      }