001// --------------------------------------------------------------------------------
002// Copyright 2002-2024 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016
017package com.echothree.model.control.party.server.graphql;
018
019import com.echothree.model.data.party.server.entity.NameSuffix;
020import com.echothree.model.data.party.server.entity.Person;
021import com.echothree.model.data.party.server.entity.PersonalTitle;
022import graphql.annotations.annotationTypes.GraphQLDescription;
023import graphql.annotations.annotationTypes.GraphQLField;
024import graphql.annotations.annotationTypes.GraphQLName;
025
026@GraphQLDescription("person object")
027@GraphQLName("Person")
028public class PersonObject {
029    
030    private final Person person; // Always Present
031    
032    public PersonObject(Person person) {
033        this.person = person;
034    }
035
036    @GraphQLField
037    @GraphQLDescription("personal title")
038    public PersonalTitleObject getPersonalTitle() {
039        PersonalTitle personalTitle = person.getPersonalTitle();
040        
041        return personalTitle == null ? null : new PersonalTitleObject(personalTitle);
042    }
043    
044    @GraphQLField
045    @GraphQLDescription("first name")
046    public String getFirstName() {
047        return person.getFirstName();
048    }
049    
050    @GraphQLField
051    @GraphQLDescription("middle name")
052    public String getMiddleName() {
053        return person.getMiddleName();
054    }
055    
056    @GraphQLField
057    @GraphQLDescription("last name")
058    public String getLastName() {
059        return person.getLastName();
060    }
061    
062    @GraphQLField
063    @GraphQLDescription("name suffix")
064    public NameSuffixObject getNameSuffix() {
065        NameSuffix nameSuffix = person.getNameSuffix();
066        
067        return nameSuffix == null ? null : new NameSuffixObject(nameSuffix);
068    }
069    
070}