All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.rocketbase.commons.model.HasFirstAndLastName Maven / Gradle / Ivy

There is a newer version: 4.4.1
Show newest version
package io.rocketbase.commons.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.util.StringUtils;

public interface HasFirstAndLastName {

    String getFirstName();

    String getLastName();

    /**
     * combines first + last name
* will return null in case firstName & lastName is empty */ @JsonIgnore default String getFullName() { boolean emptyFirstName = StringUtils.isEmpty(getFirstName()); boolean emptyLastName = StringUtils.isEmpty(getLastName()); if (emptyFirstName && emptyLastName) { return null; } else if (!emptyFirstName && !emptyLastName) { return String.format("%s %s", getFirstName(), getLastName()); } else if (!emptyFirstName) { return getFirstName(); } else { return getLastName(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy