尚硅谷大数据技术之电信客服

8) 创建类:ContactDimension

package com.atguigu.analysis.kv.impl;

import com.atguigu.analysis.kv.base.BaseDimension;

import java.io.DataInput;

import java.io.DataOutput;

import java.io.IOException;

public class ContactDimension extends BaseDimension {

    //数据库主键

    private int id;

    //手机号码

    private String telephone;

    //姓名

    private String name;

    public ContactDimension() {

        super();

    }

    public ContactDimension(String telephone, String name) {

        super();

        this.telephone = telephone;

        this.name = name;

    }

    public int getId() {

        return id;

    }

    public void setId(int id) {

        this.id = id;

    }

    public String getTelephone() {

        return telephone;

    }

    public void setTelephone(String telephone) {

        this.telephone = telephone;

    }

    public String getName() {

        return name;

    }

    public void setName(String name) {

        this.name = name;

    }

    @Override

    public boolean equals(Object o) {

        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        ContactDimension that = (ContactDimension) o;

        if (id != that.id) return false;

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

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

    }

    @Override

    public int hashCode() {

        int result = id;

        result = 31 * result + (telephone != null ? telephone.hashCode() : 0);

        result = 31 * result + (name != null ? name.hashCode() : 0);

        return result;

    }

    @Override

    public int compareTo(BaseDimension o) {

        if (o == this) return 0;

        ContactDimension contactDimension = (ContactDimension) o;

        int tmp = Integer.compare(this.id, contactDimension.getId());

        if (tmp != 0) return tmp;

        tmp = this.telephone.compareTo(contactDimension.getTelephone());

        if (tmp != 0) return tmp;

        return this.name.compareTo(contactDimension.getName());

    }

    @Override

    public void write(DataOutput dataOutput) throws IOException {

        dataOutput.writeInt(this.id);

        dataOutput.writeUTF(this.telephone);

        dataOutput.writeUTF(this.name);

    }

    @Override

    public void readFields(DataInput dataInput) throws IOException {

        this.id = dataInput.readInt();

        this.telephone = dataInput.readUTF();

        this.name = dataInput.readUTF();

    }

    @Override

    public String toString() {

        return “ContactDimension{” +

                “id=” + id +

                “, telephone=” + telephone +

                “, name='” + name + ‘\” +

                ‘}’;

    }

}


上一篇:
下一篇:
关于尚硅谷
教育理念
名师团队
学员心声
资源下载
视频下载
资料下载
工具下载
加入我们
招聘岗位
岗位介绍
招贤纳师
联系我们
全国统一咨询电话:010-56253825
地址:北京市昌平区宏福科技园综合楼6层(北京校区)

深圳市宝安区西部硅谷大厦B座C区一层(深圳校区)

上海市松江区谷阳北路166号大江商厦6层(上海校区)

武汉市东湖高新开发区东湖网谷(武汉校区)