From 2dbc4a580626ef761d8d1bd3588dba6ac86a15bf Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Wed, 8 Feb 2017 13:46:18 +0100 Subject: [PATCH] remove unused and not very elegant code --- .../de/joshavg/simpledic/Instantiator.java | 4 ---- .../de/joshavg/simpledic/IntegrityCheck.java | 23 ++++++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/joshavg/simpledic/Instantiator.java b/src/main/java/de/joshavg/simpledic/Instantiator.java index e17ccce..0b35bf2 100644 --- a/src/main/java/de/joshavg/simpledic/Instantiator.java +++ b/src/main/java/de/joshavg/simpledic/Instantiator.java @@ -30,8 +30,4 @@ class Instantiator { return constructor.newInstance(parameters); } - T createSingleton() { - return null; - } - } diff --git a/src/main/java/de/joshavg/simpledic/IntegrityCheck.java b/src/main/java/de/joshavg/simpledic/IntegrityCheck.java index 6b0fb17..3359946 100644 --- a/src/main/java/de/joshavg/simpledic/IntegrityCheck.java +++ b/src/main/java/de/joshavg/simpledic/IntegrityCheck.java @@ -92,7 +92,7 @@ class IntegrityCheck { } private void collectConstructors(ArrayList l, Constructor[] arr) { - if(arr.length == 0) { + if (arr.length == 0) { return; } @@ -101,7 +101,7 @@ class IntegrityCheck { throw new MoreThanOneConstructor(clz); } - if(!Modifier.isPublic(arr[0].getModifiers())) { + if (!Modifier.isPublic(arr[0].getModifiers())) { throw new NoVisibleConstructor(clz); } @@ -121,9 +121,7 @@ class IntegrityCheck { } private void checkCycles() { - definitions.forEach(def -> { - checkConstructorParameter(null, def.getClz()); - }); + definitions.forEach(def -> checkConstructorParameter(def.getClz(), null)); } private void checkConstructorParameter(Class rootClz, Class paramClz) { @@ -131,13 +129,16 @@ class IntegrityCheck { throw new DependencyCycleDetected(rootClz); } - Class[] parameterTypes = findDefinition(paramClz).getConstructor().getParameterTypes(); + ServiceDefinition def; + if (paramClz == null) { + def = findDefinition(rootClz); + } else { + def = findDefinition(paramClz); + } + + Class[] parameterTypes = def.getConstructor().getParameterTypes(); for (Class innerParamClz : parameterTypes) { - if (rootClz == null) { - checkConstructorParameter(paramClz, innerParamClz); - } else { - checkConstructorParameter(rootClz, innerParamClz); - } + checkConstructorParameter(rootClz, innerParamClz); } }