Primer commit

This commit is contained in:
Isidoro Nevares Martín
2026-10-07 08:29:21 +02:00
commit 4f98fbcbd1
8 changed files with 142 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-25">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Componentes_02</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
+13
View File
@@ -0,0 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=24
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=24
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=24
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,68 @@
package org.palomafp.aadd.inm;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.palomafp.aadd.inm.model.Continente;
/**
*
* AppPrincipal: Clase que realiza ....
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
* @date 7 oct 2026
*
*
*/
public class AppPrincipal {
public static void main(String[] args) {
AppPrincipal app = new AppPrincipal();
System.out.println("------------------- Probar introspección -------------------");
app.probarIntrospeccion();
System.out.println("\n------------------- Probar reflexión -------------------");
try {
app.probarReflexion();
} catch (Exception e) {
// TODO Auto-generated catch block
System.err.println(e);
}
}
private void probarIntrospeccion() {
Class<Continente> claseContinente = Continente.class;
Field[] listaCampos= claseContinente.getDeclaredFields();
Method[] listaMetodos = claseContinente.getDeclaredMethods();
System.out.println("Campos de la clase Continente:");
for (Field campo : listaCampos) {
System.out.println("\t" + campo.getName() + " - " + campo.getType().getSimpleName());
}
System.out.println("Métodos de la clase Continente:");
for (Method metodo : listaMetodos) {
System.out.println("\t" + metodo.getName() + " - " + metodo.getReturnType().getSimpleName());
}
}
private void probarReflexion() throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException {
String nombreClase = "org.palomafp.aadd.inm.model.Continente";
Class<?> claseContinente = Class.forName(nombreClase);
Object objetoContinente = claseContinente.getDeclaredConstructor().newInstance();
// Buscar el setter
Method metodoSet = claseContinente.getMethod("setCodigo", String.class);
// Ejecutar el setter
metodoSet.invoke(objetoContinente, "01");
System.out.println(objetoContinente);
}
}
@@ -0,0 +1,32 @@
package org.palomafp.aadd.inm.model;
/**
*
* Continente: Clase que se asocia a la información de un continente.
* @author Isidoro Nevares Martín - IES Virgen de la Paloma
* @date 24 sept 2026
*
*
*/
public class Continente {
private String codigo;
private String nombre;
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
@Override
public String toString() {
return "Continente [codigo=" + codigo + ", nombre=" + nombre + "]";
}
}