package org.hedgecode.snooker.json;
+import java.net.URL;
import java.util.Date;
+import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
+import org.hedgecode.snooker.SnookerURLUtils;
+import org.hedgecode.snooker.annotation.IsURL;
+import org.hedgecode.snooker.api.APIException;
import org.hedgecode.snooker.api.Player;
+import org.hedgecode.snooker.api.PlayerImage;
/**
* Player Entity to JSON deserialize.
private int teamSeason;
@SerializedName("ShortName")
private String shortName;
+ @Expose
+ private String fullName;
@SerializedName("Nationality")
private String nationality;
@SerializedName("Sex")
private String sex;
+ @IsURL
@SerializedName("BioPage")
private String bioPage;
@SerializedName("Born")
private String license;
@SerializedName("Club")
private String club;
+ @IsURL
@SerializedName("URL")
private String url;
+ @IsURL
@SerializedName("Photo")
private String photo;
+ @Expose
+ private PlayerImage image;
+ @IsURL
+ @SerializedName("PhotoSource")
+ private String photoSource;
+ @SerializedName("FirstSeasonAsPro")
+ private int firstSeasonAsPro;
+ @SerializedName("LastSeasonAsPro")
+ private int lastSeasonAsPro;
@SerializedName("Info")
private String info;
}
@Override
+ public String fullName() {
+ if (fullName == null) {
+ fullName = String.format(
+ "%s %s %s",
+ surnameFirst ? lastName : firstName,
+ middleName,
+ surnameFirst ? firstName : lastName
+ ).replaceAll("\\s+", " ").trim();
+ }
+ return fullName;
+ }
+
+ @Override
public String nationality() {
return nationality;
}
return twitter;
}
+ @IsURL
+ @Override
+ public String twitterUrl() {
+ return SnookerURLUtils.twitterUrl(twitter);
+ }
+
@Override
public boolean surnameFirst() {
return surnameFirst;
}
@Override
+ public PlayerImage image() throws APIException {
+ if (image == null) {
+ URL imageUrl = SnookerURLUtils.assignUrl(photo);
+ if (imageUrl != null) {
+ image = new PlayerImage(imageUrl, false);
+ }
+ }
+ return image;
+ }
+
+ @Override
+ public String photoSource() {
+ return photoSource;
+ }
+
+ @Override
+ public int firstSeasonAsPro() {
+ return firstSeasonAsPro;
+ }
+
+ @Override
+ public int lastSeasonAsPro() {
+ return lastSeasonAsPro;
+ }
+
+ @Override
public String info() {
return info;
}