1 package com.foxinmy.weixin4j.mp.model;
2
3 import java.io.Serializable;
4
5 import com.alibaba.fastjson.annotation.JSONCreator;
6 import com.alibaba.fastjson.annotation.JSONField;
7
8
9
10
11
12
13
14
15 public class Group implements Serializable {
16
17 private static final long serialVersionUID = 6979565973974005954L;
18
19
20
21
22 private int id;
23
24
25
26 private String name;
27
28
29
30 private int count;
31
32 public Group(int id, String name) {
33 this.id = id;
34 this.name = name;
35 }
36
37 public Group(String name) {
38 this.name = name;
39 }
40
41 @JSONCreator
42 public Group(@JSONField(name = "id") int id,
43 @JSONField(name = "name") String name,
44 @JSONField(name = "count") int count) {
45 this.id = id;
46 this.name = name;
47 this.count = count;
48 }
49
50 public int getId() {
51 return id;
52 }
53
54 public String getName() {
55 return name;
56 }
57
58 public int getCount() {
59 return count;
60 }
61
62
63
64
65
66
67 public String toCreateJson() {
68 return String.format("{\"group\":{\"name\":\"%s\"}}", name);
69 }
70
71
72
73
74
75
76 public String toModifyJson() {
77 return String.format("{\"group\":{\"id\":%s,\"name\":\"%s\"}}", id,
78 name);
79 }
80
81 @Override
82 public boolean equals(Object obj) {
83 if (obj instanceof Group) {
84 return id == ((Group) obj).getId();
85 }
86 return super.equals(obj);
87 }
88
89 @Override
90 public int hashCode() {
91 final int prime = 31;
92 int result = 1;
93 result = prime * result + count;
94 result = prime * result + id;
95 result = prime * result + ((name == null) ? 0 : name.hashCode());
96 return result;
97 }
98
99 @Override
100 public String toString() {
101 return String.format("[Group id=%d ,name=%s ,count=%d]", id, name,
102 count);
103 }
104 }