@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); Person person = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); Log.i(TAG, "Gender: " + person.getGender()); } }
new CheckPerson() { public boolean test(Person p) { return p.getGender() == Person.Sex.MALE; } }
public class FemaleTest implements CheckPerson { public boolean test (Person p) { return p.getGender().equals("Female"); } }
int females = 0; int males = 0; for(Person person : ppl) { switch(person.getGender()) { case Gender.MALE: males++; break; case Gender.FEMALE: females++; break; case Gender.SHEMALE_WTF: //hmm? males++; females++; break; // but I would just: // throw new SecurityException("SYSTEM GOT VIRUS!!!!"); } }
public class PeopleList { private List<Person> men; private List<Person> women; public Person get(char gender, int position){ switch (gender){ case 'M': return men.elementAt(position); case 'W': return women.elementAt(position); } } public void insert(Person p){ switch(p.getGender()){ case 'M': men.insert(p); break; case 'W': women.insert(p); break; } } }
/** * @see PersonService#savePerson(Person) */ @Test public void savePerson_shouldUpdateExistingObjectWhenPersonIdIsNotNull() throws Exception { Person personSaved = Context.getPersonService().getPerson(1); Assert.assertNotNull(personSaved.getId()); personSaved.setGender("M"); Person personUpdated = Context.getPersonService().savePerson(personSaved); Assert.assertEquals("M", personUpdated.getGender()); }
if (person.getGender() == null) { errors.rejectValue("person.gender", "error.null");
public class Main { public static void main(String[] args) { Gson g = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create(); Person person = g.fromJson("{\"name\":\"Jhon\",\"lastName\":\"Smith\",\"clothes\":{\"gender\":\"male\",\"Shirt\":{\"id\":113608,\"name\":\"Green Shirt\",\"size\":\"Large\"},\"Pants\":{\"id\":115801,\"name\":\"Black Leather Pants\",\"size\":\"Large\"}}}", Person.class); System.out.println(person.getClothes()); System.out.println(person.getGender()); } }
attributes = person.getAttributes(); gender = person.getGender(); birthdate = person.getBirthdate(); birthtime = person.getBirthDateTime();
jTextField17.setText(updatePerson.getSurname()); jTextField12.setText(updatePerson.getPersontype()); jTextField16.setText(updatePerson.getGender()); jSpinner5.setValue(updatePerson.getDateofbirth());
@Test public void shouldGetAPersonByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); Person person = service.getPersonByUuid(getUuid()); assertEquals(person.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertNotNull(PropertyUtils.getProperty(result, "preferredName")); assertEquals(person.getGender(), PropertyUtils.getProperty(result, "gender")); assertNull(PropertyUtils.getProperty(result, "auditInfo")); }
public static OpenMRSPerson openMRSToMRSPerson(Person person) { Set<PersonName> personNames = person.getNames(); PersonName personName = getFirstName(personNames); final List<OpenMRSAttribute> attributes = project(person.getAttributes(), OpenMRSAttribute.class, on(PersonAttribute.class).getAttributeType().toString(), on(PersonAttribute.class).getValue()); List<MRSAttribute> personAttributes = new ArrayList<MRSAttribute>(); personAttributes.addAll(attributes); OpenMRSPerson mrsPerson = new OpenMRSPerson().firstName(personName.getGivenName()).middleName(personName.getMiddleName()) .lastName(personName.getFamilyName()).birthDateEstimated(person.getBirthdateEstimated()).gender(person.getGender()).age(person.getAge()) .address(getAddress(person)).attributes(personAttributes).dateOfBirth(new DateTime(person.getBirthdate())).dead(person.isDead()).deathDate(new DateTime(person.getDeathDate())); if (person.getId() != null) { mrsPerson.id(Integer.toString(person.getId())); } return mrsPerson; }
@Test public void shouldEditAPerson() throws Exception { Person person = service.getPersonByUuid(getUuid()); assertFalse("F".equals(person.getGender())); assertFalse(person.isDead()); assertNull(person.getCauseOfDeath()); String json = "{\"gender\":\"F\",\"dead\":true, \"causeOfDeath\":\"15f83cd6-64e9-4e06-a5f9-364d3b14a43d\"}"; SimpleObject response = deserialize(handle(newPostRequest(getURI() + "/" + getUuid(), json))); assertNotNull(response); Object responsePersonContents = PropertyUtils.getProperty(response, "person"); assertNotNull(responsePersonContents); assertTrue("F".equals(PropertyUtils.getProperty(responsePersonContents, "gender").toString())); assertEquals("F", person.getGender()); assertTrue(person.isDead()); assertNotNull(person.getCauseOfDeath()); }
@Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropEquals("gender", getObject().getGender()); assertPropEquals("age", getObject().getAge()); assertPropEquals("birthdate", getObject().getBirthdate()); assertPropEquals("birthdateEstimated", getObject().getBirthdateEstimated()); assertPropEquals("dead", getObject().getDead()); assertPropEquals("deathDate", getObject().getDeathDate()); assertPropPresent("causeOfDeath"); assertPropPresent("preferredName"); assertPropPresent("preferredAddress"); assertPropPresent("attributes"); assertPropEquals("voided", getObject().getVoided()); }
@Override public void validateFullRepresentation() throws Exception { super.validateFullRepresentation(); assertPropEquals("gender", getObject().getGender()); assertPropEquals("age", getObject().getAge()); assertPropEquals("birthdate", getObject().getBirthdate()); assertPropEquals("birthdateEstimated", getObject().getBirthdateEstimated()); assertPropEquals("dead", getObject().getDead()); assertPropEquals("deathDate", getObject().getDeathDate()); assertPropPresent("causeOfDeath"); assertPropPresent("preferredName"); assertPropPresent("preferredAddress"); assertPropPresent("names"); assertPropPresent("addresses"); assertPropPresent("attributes"); assertPropEquals("voided", getObject().getVoided()); assertPropPresent("auditInfo"); }