Add gender to Person

This commit is contained in:
Stuart Boston
2016-03-19 19:33:27 +00:00
parent bab9c80781
commit e83d947dfe
2 changed files with 61 additions and 0 deletions
@@ -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 <http://www.gnu.org/licenses/>.
*
*/
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;
}
}
}
@@ -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<PeopleMethod> 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);