• 通过Comparable来实现对自身的比较


    import org.apache.commons.lang.builder.CompareToBuilder;
    import org.apache.commons.lang.builder.EqualsBuilder;
    import org.apache.commons.lang.builder.HashCodeBuilder;
    import org.apache.commons.lang.builder.ToStringBuilder;
    import org.apache.commons.lang.builder.ToStringStyle;
     
    /**
     * The Class Book.
     */
    public class Book implements Comparable<book> {
     
     /** The id. */
     private long id;
     
     /** The name. */
     private String name;
     
     /**
      * Instantiates a new book.
      */
     public Book() {
     }
     
     /**
      * Gets the id.
      *
      * @return the id
      */
     public long getId() {
      return id;
     }
     
     /**
      * Sets the id.
      *
      * @param id
      *            the new id
      */
     public void setId(long id) {
      this.id = id;
     }
     
     /**
      * Gets the name.
      *
      * @return the name
      */
     public String getName() {
      return name;
     }
     
     /**
      * Sets the name.
      *
      * @param name
      *            the new name
      */
     public void setName(String name) {
      this.name = name;
     }
     
     /*
      * (non-Javadoc)
      *
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
     public int compareTo(Book o) {
      return new CompareToBuilder().append(this.getId(), o.getId()).toComparison();
     }
    }
  • 相关阅读:
    详解用em替换px
    js判断是否为ie浏览器
    nth-child()选择器小结
    HTML5之canvas
    MQTT-SN协议乱翻之消息格式
    MQTT-SN协议乱翻之简要介绍
    MQTT 3.1.1,值得升级的6个新特性
    MQTT 3.1协议非严肃反思录
    MQTT协议笔记之mqtt.io项目HTTP协议支持
    MQTT协议笔记之mqtt.io项目Websocket协议支持
  • 原文地址:https://www.cnblogs.com/frankyou/p/10593551.html
Copyright © 2020-2023  润新知