package  ch.openech.model.person;

import org.minimalj.model.Keys;
import org.minimalj.model.annotation.Size;
import org.minimalj.util.StringUtils;

import ch.openech.model.EchFormats;

/**
 * 
 * Verwendet in der Person, einmal für Mutter, einmal für Vater
 */
public class NameOfParent {
	public static final NameOfParent $ = Keys.of(NameOfParent.class);

	@Size(EchFormats.officialFirstName)
	public String firstName;
	@Size(EchFormats.baseName)
	public String officialName;
	
	public Boolean officialProof;
	
	public boolean isEmpty() {
		return StringUtils.isEmpty(firstName) && StringUtils.isEmpty(officialName); 
	}
	
	public String display() {
		if (StringUtils.isEmpty(firstName)) {
			if (!StringUtils.isEmpty(officialName)) {
				return officialName;
			} else {
				return null;
			}
		} else {
			if (!StringUtils.isEmpty(officialName)) {
				return officialName + ", " + firstName;
			} else {
				return firstName;
			}
		}
	}
	
}

@@ -60,16 +60,53 @@
 l.Keys;%0A
+import org.minimalj.model.Rendering;%0A
 import o
@@ -318,16 +318,37 @@
 fParent 
+implements Rendering 
 %7B%0A%09publi
@@ -676,16 +676,27 @@
 ; %0A%09%7D%0A%09%0A
+%09@Override%0A
 %09public 
@@ -706,16 +706,36 @@
 ing 
-display(
+render(RenderType renderType
 ) %7B%0A

implement Rendering