public class Profesor implements Serializable { private int id; private Nombre nombre; public Profesor(){ } public Profesor(int id, Nombre nombre) { this.id = id; this.nombre=nombre; } } public class Nombre implements Serializable { private String nombre; private String ape1; private String ape2; public Nombre() { } public Nombre(String nombre, String ape1, String ape2) { this.nombre = nombre; this.ape1 = ape1; this.ape2 = ape2; } public String getNombreCompleto() { StringBuilder sb=new StringBuilder(); if ((ape1!=null) && (ape1.trim().length()>0)) { sb.append(ape1); } if ((ape2!=null) && (ape2.trim().length()>0)) { if (sb.length()>0) { sb.append(" "); } sb.append(ape2); } if ((nombre!=null) && (nombre.trim().length()>0)) { if (sb.length()>0) { sb.append(","); } sb.append(nombre); } return sb.toString(); } public String getIniciales() { StringBuilder sb=new StringBuilder(); if ((nombre!=null) && (nombre.trim().length()>0)) { sb.append(nombre.substring(0,1)); } if ((ape1!=null) && (ape1.trim().length()>0)) { sb.append(ape1.substring(0,1)); } if ((ape2!=null) && (ape2.trim().length()>0)) { sb.append(ape2.substring(0,1)); } return sb.toString().toUpperCase(); } }