All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.backendless.marketplace.model.BlConfigurationItemDescription Maven / Gradle / Ivy

The newest version!
package com.backendless.marketplace.model;

import com.backendless.commons.model.ConfigurationItemType;
import com.backendless.util.persistence.AbstractBackendlessDataObject;
import com.backendless.util.persistence.IEntity;
import com.backendless.writer.serialization.BlConfigurationItemDescriptionOptionsDeserializer;
import com.backendless.writer.serialization.BlConfigurationItemDescriptionOptionsSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * User: Eugene Chipachenko
 * Date: 23.07.14
 * Time: 16:43
 */
public class BlConfigurationItemDescription extends AbstractBackendlessDataObject implements Serializable, IEntity,
                                                                                             Comparable
{
  private static final long serialVersionUID = 1869742445209388240L;

  private String name;
  private String displayName;
  private ConfigurationItemType type;
  private String defaultValue;
  private Boolean required;
  //we could not save collection of primitives to our persistence so have to convert to string
  private String options;
  private String hint;
  private String localServiceVersion;
  private Integer order = 0;

  public BlConfigurationItemDescription()
  {
  }

  public String getName()
  {
    return name;
  }

  public void setName( String name )
  {
    this.name = name;
  }

  public String getDisplayName()
  {
    return displayName;
  }

  public void setDisplayName( String displayName )
  {
    this.displayName = displayName;
  }

  public ConfigurationItemType getType()
  {
    return type;
  }

  public void setType( ConfigurationItemType type )
  {
    this.type = type;
  }

  public String getDefaultValue()
  {
    return defaultValue;
  }

  public void setDefaultValue( String defaultValue )
  {
    this.defaultValue = defaultValue;
  }

  public Boolean getRequired()
  {
    return required;
  }

  public void setRequired( Boolean required )
  {
    this.required = required;
  }

  @JsonSerialize( using = BlConfigurationItemDescriptionOptionsSerializer.class )
  public String getOptions()
  {
    return options;
  }

  @JsonDeserialize( using = BlConfigurationItemDescriptionOptionsDeserializer.class )
  public void setOptions( String options )
  {
    this.options = options;
  }

  public String getHint()
  {
    return hint;
  }

  public void setHint( String hint )
  {
    this.hint = hint;
  }

  public String getLocalServiceVersion()
  {
    return localServiceVersion;
  }

  public void setLocalServiceVersion( String localServiceVersion )
  {
    this.localServiceVersion = localServiceVersion;
  }

  public void setArrayOptions( String options[] )
  {
    if( options == null )
      return;

    this.options = "";

    for( int i = 0; i < options.length; i++ )
    {
      String option = options[ i ];
      this.options += option;

      if( i != options.length - 1 )
        this.options += ",";
    }

  }

  public Integer getOrder()
  {
    return order;
  }

  public void setOrder( Integer order )
  {
    this.order = order;
  }

  @Override
  public boolean equals( Object o )
  {
    if( this == o )
      return true;
    if( o == null || getClass() != o.getClass() )
      return false;
    if( !super.equals( o ) )
      return false;

    BlConfigurationItemDescription that = (BlConfigurationItemDescription) o;

    if( name != null ? !name.equals( that.name ) : that.name != null )
      return false;
    if( displayName != null ? !displayName.equals( that.displayName ) : that.displayName != null )
      return false;
    if( type != that.type )
      return false;
    if( defaultValue != null ? !defaultValue.equals( that.defaultValue ) : that.defaultValue != null )
      return false;
    if( required != null ? !required.equals( that.required ) : that.required != null )
      return false;
    if( options != null ? !options.equals( that.options ) : that.options != null )
      return false;

    if( hint != null ? !hint.equals( that.hint ) : that.hint != null )
      return false;

    if( order != null ? !order.equals( that.order ) : that.order != null )
      return false;

    if( !super.equals( that ) )
      return false;

    return !(localServiceVersion != null ? !localServiceVersion.equals( that.localServiceVersion ) : that.localServiceVersion != null);
  }

  @Override
  public int hashCode()
  {
    int result = super.hashCode();
    result = 31 * result + (name != null ? name.hashCode() : 0);
    result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
    result = 31 * result + (type != null ? type.hashCode() : 0);
    result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
    result = 31 * result + (required != null ? required.hashCode() : 0);
    result = 31 * result + (options != null ? options.hashCode() : 0);
    result = 31 * result + (hint != null ? hint.hashCode() : 0);
    result = 31 * result + (order != null ? order.hashCode() : 0);
    result = 31 * result + (localServiceVersion != null ? localServiceVersion.hashCode() : 0);
    return result;
  }

  @Override
  public int compareTo( BlConfigurationItemDescription o )
  {
    final int valueCompareTo = getValueCompareTo( o );
    return valueCompareTo == 0
            ? this.equals( o ) ? 0 : -1
            : valueCompareTo;
  }

  private int getValueCompareTo( BlConfigurationItemDescription o )
  {
    if( order == null )
      return o == null ? 0 : o.order == null ? 0 : o.order;

    if( o == null || o.order == null )
      return order;

    return order - o.order;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy