001/*
002 * Copyright (c) 2007-2015 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
021package cascading.flow.planner;
022
023import java.io.Serializable;
024
025/**
026 *
027 */
028public class PlatformInfo implements Serializable, Comparable<PlatformInfo>
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 int compareTo( PlatformInfo other )
043    {
044    if( other == null )
045      return 1;
046
047    return this.toString().compareTo( other.toString() );
048    }
049
050  @Override
051  public boolean equals( Object object )
052    {
053    if( this == object )
054      return true;
055    if( object == null || getClass() != object.getClass() )
056      return false;
057
058    PlatformInfo that = (PlatformInfo) object;
059
060    if( name != null ? !name.equals( that.name ) : that.name != null )
061      return false;
062    if( vendor != null ? !vendor.equals( that.vendor ) : that.vendor != null )
063      return false;
064    if( version != null ? !version.equals( that.version ) : that.version != null )
065      return false;
066
067    return true;
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    if( name == null )
085      sb.append( "UNKNOWN" ).append( ':' );
086    else
087      sb.append( name ).append( ':' );
088
089    if( version != null )
090      sb.append( version ).append( ':' );
091
092    if( vendor != null )
093      sb.append( vendor );
094
095    return sb.toString();
096    }
097  }