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

play.plugins.PluginDescriptor Maven / Gradle / Ivy

There is a newer version: 2.6.3
Show newest version
package play.plugins;

import java.net.URL;
import java.util.Objects;

import static java.util.Objects.hash;

public class PluginDescriptor implements Comparable {
  public final String name;
  public final int index;
  public final URL url;

  public PluginDescriptor(String name, int index, URL url) {
    this.name = name;
    this.index = index;
    this.url = url;
  }

  @Override
  public String toString() {
    return String.format("PluginDescriptor{name='%s', index=%s, url=%s}", name, index, url);
  }

  @Override
  public int compareTo(PluginDescriptor o) {
    int res = Integer.compare(index, o.index);
    if (res != 0) {
      return res;
    }

    // Index is equal in both plugins.
    // sort on name to get consistent order
    return name.compareTo(o.name);
  }

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

    PluginDescriptor that = (PluginDescriptor) o;
    return Objects.equals(index, that.index) && Objects.equals(name, that.name);
  }

  @Override
  public int hashCode() {
    return hash(name, index);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy