diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF deleted file mode 100644 index 58630c02..00000000 --- a/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -Manifest-Version: 1.0 - diff --git a/META-INF/javaFaker.jardesc b/META-INF/javaFaker.jardesc deleted file mode 100644 index 5324d6af..00000000 --- a/META-INF/javaFaker.jardesc +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/bin/javaFaker_0.18.1.jar b/bin/javaFaker_0.18.1.jar deleted file mode 100644 index d07893b8..00000000 Binary files a/bin/javaFaker_0.18.1.jar and /dev/null differ diff --git a/src/main/java/com/github/javafaker/Relationships.java b/src/main/java/com/github/javafaker/Relationships.java index 81eb6455..e563e111 100644 --- a/src/main/java/com/github/javafaker/Relationships.java +++ b/src/main/java/com/github/javafaker/Relationships.java @@ -2,9 +2,13 @@ package com.github.javafaker; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.logging.Logger; + +import org.apache.commons.lang3.ArrayUtils; public class Relationships { private final Faker faker; + private static final Logger logger = Logger.getLogger("Relationships"); protected Relationships(final Faker faker) { this.faker = faker; @@ -18,7 +22,7 @@ public class Relationships { return faker.resolve("relationship.familial.extended"); } - public String in_law() { + public String inLaw() { return faker.resolve("relationship.in_law"); } @@ -35,25 +39,24 @@ public class Relationships { } public String any() { - String[] relationships = new String[] {"direct", "extended", "in_law", "spouse", - "parent", "sibling"}; - int idx = faker.random().nextInt(relationships.length); - String methodName = relationships[idx]; + Method currentMethod = Relationships.class.getClass().getEnclosingMethod(); + try { - Method m = Relationships.class.getMethod(methodName); - Relationships relInstance = new Relationships(faker); - return (String)m.invoke(relInstance); - } catch (NoSuchMethodException e) { - e.printStackTrace(); + Method[] methods = Relationships.class.getDeclaredMethods(); + methods = ArrayUtils.removeElement(methods, currentMethod); + int indx = faker.random().nextInt(methods.length); + Method runMethod = methods[indx]; + Relationships relationships = new Relationships(faker); + return (String)runMethod.invoke(relationships); } catch (SecurityException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); + throw new RuntimeException("SecurityException: " + e.getMessage()); } catch (IllegalArgumentException e) { - e.printStackTrace(); + throw new RuntimeException("IllegalArgumentException: " + e.getMessage()); + } catch (IllegalAccessException e) { + throw new RuntimeException("IllegalAccessException: " + e.getMessage()); } catch (InvocationTargetException e) { - e.printStackTrace(); + throw new RuntimeException("InvocationTargetException: " + e.getMessage()); } - return null; } + } \ No newline at end of file diff --git a/src/main/resources/en/heroes.yml b/src/main/resources/en/heroes.yml old mode 100755 new mode 100644 diff --git a/src/test/java/com/github/javafaker/RelationshipTest.java b/src/test/java/com/github/javafaker/RelationshipTest.java index c848870e..33d53118 100644 --- a/src/test/java/com/github/javafaker/RelationshipTest.java +++ b/src/test/java/com/github/javafaker/RelationshipTest.java @@ -24,8 +24,8 @@ public class RelationshipTest extends AbstractFakerTest { } @Test - public void in_lawTest() { - assertThat(faker.relationships().in_law(), not(isEmptyOrNullString())); + public void inLawTest() { + assertThat(faker.relationships().inLaw(), not(isEmptyOrNullString())); } @Test