43 lines
1.0 KiB
Java
43 lines
1.0 KiB
Java
package com.github.catvod.bean;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.annotations.SerializedName;
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
import java.lang.reflect.Type;
|
|
import java.util.List;
|
|
|
|
public class Class {
|
|
|
|
@SerializedName("type_id")
|
|
private String typeId;
|
|
@SerializedName("type_name")
|
|
private String typeName;
|
|
|
|
public static List<Class> arrayFrom(String str) {
|
|
Type listType = new TypeToken<List<Class>>() {}.getType();
|
|
return new Gson().fromJson(str, listType);
|
|
}
|
|
|
|
public Class(int typeId, String typeName) {
|
|
this(String.valueOf(typeId), typeName);
|
|
}
|
|
|
|
public Class(String typeId, String typeName) {
|
|
this.typeId = typeId;
|
|
this.typeName = typeName;
|
|
}
|
|
|
|
public String getTypeId() {
|
|
return typeId;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) return true;
|
|
if (!(obj instanceof Class)) return false;
|
|
Class it = (Class) obj;
|
|
return getTypeId().equals(it.getTypeId());
|
|
}
|
|
}
|