Métodos de servicio

This commit is contained in:
Isidoro Nevares Martín 2026-03-09 17:01:42 +01:00
parent 64276be426
commit 8c47a2ed9e
4 changed files with 56 additions and 45 deletions

View File

@ -12,22 +12,9 @@
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
@ -38,19 +25,19 @@
</classpathentry> </classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations"> <classpathentry kind="src" path="target/generated-sources/annotations">
<attributes> <attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/> <attribute name="m2e-apt" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes> <attributes>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/> <attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>

View File

@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8

View File

@ -3,10 +3,31 @@
*/ */
package org.lapaloma.hogwarts.service; package org.lapaloma.hogwarts.service;
/** import org.lapaloma.hogwarts.vo.Casa;
* Isidoro Nevares Martín - Virgen de la Paloma
* Fecha creación: 9 mar 2026
*/
public class CasaService {
/**
* Isidoro Nevares Martín - Virgen de la Paloma Fecha creación: 9 mar 2026
*/
public class CasaService {
public boolean tieneNombre(Casa casa) {
if (casa == null) {
return false;
}
String nombre = casa.getNombre();
return nombre != null && !nombre.trim().isEmpty();
}
public String obtenerNnombreEnMayusculas(Casa casa) {
if (!tieneNombre(casa)) {
return null;
}
return casa.getNombre().toUpperCase();
}
public boolean esCasaValida(Casa casa) {
if (casa == null || casa.getIdentificador() <= 0) {
return false;
}
return tieneNombre(casa);
}
} }

View File

@ -10,27 +10,28 @@ package org.lapaloma.hogwarts.vo;
* *
*/ */
public class Casa { public class Casa {
private int identificador; private int identificador;
String nombre; String nombre;
public int getIdentificador() {
return identificador;
}
public void setIdentificador(int identificador) {
this.identificador = identificador;
}
public int getIdentificador() { public String getNombre() {
return identificador; return nombre;
} }
public void setIdentificador(int identificador) {
this.identificador = identificador;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
@Override
public String toString() {
return "Casa [identificador=" + identificador + ", nombre=" + nombre + "]";
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
@Override
public String toString() {
return "Casa [identificador=" + identificador + ", nombre=" + nombre + "]";
}
} }