diff --git a/src/main/java/com/omertron/themoviedbapi/enumeration/Gender.java b/src/main/java/com/omertron/themoviedbapi/enumeration/Gender.java new file mode 100644 index 000000000..4b6c8b1ce --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/enumeration/Gender.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004-2016 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.enumeration; + +public enum Gender { + MALE(1), + FEMALE(2), + UNKNOWN(0); + + private final int type; + + private Gender(int type) { + this.type = type; + } + + /** + * Get the gender from an integer type + * + * @param iType + * @return + */ + public static Gender fromInteger(int iType) { + switch (iType) { + case 1: + return MALE; + case 2: + return FEMALE; + default: + return UNKNOWN; + } + } + +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java b/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java index 8d3335c83..90a1f0349 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/person/PersonInfo.java @@ -21,6 +21,7 @@ package com.omertron.themoviedbapi.model.person; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.omertron.themoviedbapi.enumeration.Gender; import com.omertron.themoviedbapi.enumeration.PeopleMethod; import com.omertron.themoviedbapi.interfaces.AppendToResponse; import com.omertron.themoviedbapi.model.artwork.Artwork; @@ -62,6 +63,7 @@ public class PersonInfo extends PersonBasic implements Serializable, AppendToRes private String placeOfBirth; @JsonProperty("popularity") private float popularity; + private Gender gender; // AppendToResponse private final Set methods = EnumSet.noneOf(PeopleMethod.class); // AppendToResponse Properties @@ -150,6 +152,15 @@ public class PersonInfo extends PersonBasic implements Serializable, AppendToRes methods.add(method); } + public Gender getGender() { + return gender; + } + + @JsonSetter("gender") + public void setGender(int gender) { + this.gender = Gender.fromInteger(gender); + } + @Override public boolean hasMethod(PeopleMethod method) { return methods.contains(method);