@Test @DisplayName("creates the expected fingerprint for the methods") void testFingerprint2Method() throws BadSyntax { Assertions.assertEquals("argless",EntityStringer.fingerprint2Method("javax0.geci.jamal.util.TestEntityStringer|argless").getName()); Assertions.assertEquals("arg1pri",EntityStringer.fingerprint2Method("javax0.geci.jamal.util.TestEntityStringer|arg1pri|int[][]").getName()); Assertions.assertEquals("arg1obj",EntityStringer.fingerprint2Method("javax0.geci.jamal.util.TestEntityStringer|arg1obj|java.lang.Integer").getName()); Assertions.assertEquals("arg1objarr",EntityStringer.fingerprint2Method("javax0.geci.jamal.util.TestEntityStringer|arg1objarr|java.util.Map|java.util.Set[]").getName()); }
public static Method fingerprint2Method(String fingerprint) throws BadSyntax { final var parts = fingerprint.split("\\|", -1); if (parts.length < 2) { throw new BadSyntax("Method fingerprint '" + fingerprint + "' is badly formatted, does not have 'class|name' parts."); } try { final var klass = GeciReflectionTools.classForName(parts[0]); final var name = parts[1]; if (parts.length > 2) { final var argClasses = Arrays.stream(parts).skip(2).map(EntityStringer::forName).toArray(Class[]::new); return GeciReflectionTools.getMethod(klass, name, argClasses); } else { return GeciReflectionTools.getMethod(klass, name); } } catch (ClassNotFoundException e) { throw new BadSyntax("Class in fingerprint '" + fingerprint + "' cannot be found.", e); } catch (NoSuchMethodException e) { throw new BadSyntax("Method in fingerprint '" + fingerprint + "' cannot be found.", e); } }
EntityStringer { public static Method fingerprint2Method(String fingerprint) throws BadSyntax { final var parts = fingerprint.split("\\|", -1); if (parts.length < 2) { throw new BadSyntax("Method fingerprint '" + fingerprint + "' is badly formatted, does not have 'class|name' parts."); } try { final var klass = GeciReflectionTools.classForName(parts[0]); final var name = parts[1]; if (parts.length > 2) { final var argClasses = Arrays.stream(parts).skip(2).map(EntityStringer::forName).toArray(Class[]::new); return GeciReflectionTools.getMethod(klass, name, argClasses); } else { return GeciReflectionTools.getMethod(klass, name); } } catch (ClassNotFoundException e) { throw new BadSyntax("Class in fingerprint '" + fingerprint + "' cannot be found.", e); } catch (NoSuchMethodException e) { throw new BadSyntax("Method in fingerprint '" + fingerprint + "' cannot be found.", e); } } }
EntityStringer { public static Method fingerprint2Method(String fingerprint) throws BadSyntax { final var parts = fingerprint.split("\\|", -1); if (parts.length < 2) { throw new BadSyntax("Method fingerprint '" + fingerprint + "' is badly formatted, does not have 'class|name' parts."); } try { final var klass = GeciReflectionTools.classForName(parts[0]); final var name = parts[1]; if (parts.length > 2) { final var argClasses = Arrays.stream(parts).skip(2).map(EntityStringer::forName).toArray(Class[]::new); return GeciReflectionTools.getMethod(klass, name, argClasses); } else { return GeciReflectionTools.getMethod(klass, name); } } catch (ClassNotFoundException e) { throw new BadSyntax("Class in fingerprint '" + fingerprint + "' cannot be found.", e); } catch (NoSuchMethodException e) { throw new BadSyntax("Method in fingerprint '" + fingerprint + "' cannot be found.", e); } }  }
EntityStringer { public static Method fingerprint2Method(String fingerprint) throws BadSyntax { final var parts = fingerprint.split("\\|", -1); if (parts.length < 2) { throw new BadSyntax("Method fingerprint '" + fingerprint + "' is badly formatted, does not have 'class|name' parts."); } try { final var klass = GeciReflectionTools.classForName(parts[0]); final var name = parts[1]; if (parts.length > 2) { final var argClasses = Arrays.stream(parts).skip(2).map(EntityStringer::forName).toArray(Class[]::new); return GeciReflectionTools.getMethod(klass, name, argClasses); } else { return GeciReflectionTools.getMethod(klass, name); } } catch (ClassNotFoundException e) { throw new BadSyntax("Class in fingerprint '" + fingerprint + "' cannot be found.", e); } catch (NoSuchMethodException e) { throw new BadSyntax("Method in fingerprint '" + fingerprint + "' cannot be found.", e); } }  static String method2Fingerprint(Method method); static String field2Fingerprint(Field field); static Method fingerprint2Method(String fingerprint); static boolean isFingerPrintAField(String fingerPrint); static Field fingerprint2Field(String fingerprint); }
EntityStringer { public static Method fingerprint2Method(String fingerprint) throws BadSyntax { final var parts = fingerprint.split("\\|", -1); if (parts.length < 2) { throw new BadSyntax("Method fingerprint '" + fingerprint + "' is badly formatted, does not have 'class|name' parts."); } try { final var klass = GeciReflectionTools.classForName(parts[0]); final var name = parts[1]; if (parts.length > 2) { final var argClasses = Arrays.stream(parts).skip(2).map(EntityStringer::forName).toArray(Class[]::new); return GeciReflectionTools.getMethod(klass, name, argClasses); } else { return GeciReflectionTools.getMethod(klass, name); } } catch (ClassNotFoundException e) { throw new BadSyntax("Class in fingerprint '" + fingerprint + "' cannot be found.", e); } catch (NoSuchMethodException e) { throw new BadSyntax("Method in fingerprint '" + fingerprint + "' cannot be found.", e); } }  static String method2Fingerprint(Method method); static String field2Fingerprint(Field field); static Method fingerprint2Method(String fingerprint); static boolean isFingerPrintAField(String fingerPrint); static Field fingerprint2Field(String fingerprint);  }