From 0c1493b9278b8ea4aeb3a94ed5a3fbf44b2a597b Mon Sep 17 00:00:00 2001 From: mbazos Date: Mon, 12 Feb 2018 10:16:28 -0500 Subject: [PATCH] Compile at JDK 1.6 #17 --- .gitignore | 14 ++++++++ .../java/org/codejargon/feather/Feather.java | 33 +++++++++++++------ .../main/java/org/codejargon/feather/Key.java | 9 ++--- pom.xml | 12 +++---- 4 files changed, 48 insertions(+), 20 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bcc6fd1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +########### +# PROJECT # +########### +*.settings/ +*.project +*.classpath +*log +**/target/ +*.iml + +######## +# IDEA # +######## +/.idea/* \ No newline at end of file diff --git a/feather/src/main/java/org/codejargon/feather/Feather.java b/feather/src/main/java/org/codejargon/feather/Feather.java index d024f2d..f9e2d59 100644 --- a/feather/src/main/java/org/codejargon/feather/Feather.java +++ b/feather/src/main/java/org/codejargon/feather/Feather.java @@ -1,15 +1,28 @@ package org.codejargon.feather; -import javax.inject.*; import java.lang.annotation.Annotation; -import java.lang.reflect.*; -import java.util.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import javax.inject.Inject; +import javax.inject.Provider; +import javax.inject.Qualifier; +import javax.inject.Singleton; + public class Feather { - private final Map> providers = new ConcurrentHashMap<>(); - private final Map singletons = new ConcurrentHashMap<>(); - private final Map injectFields = new ConcurrentHashMap<>(0); + private final Map> providers = new ConcurrentHashMap>(); + private final Map singletons = new ConcurrentHashMap(); + private final Map injectFields = new ConcurrentHashMap(0); /** * Constructs Feather with configuration modules @@ -82,7 +95,7 @@ public void injectFields(Object target) { Field field = (Field) f[0]; Key key = (Key) f[2]; try { - field.set(target, (boolean) f[1] ? provider(key) : instance(key)); + field.set(target, ((Boolean) f[1]).booleanValue() ? provider(key) : instance(key)); } catch (Exception e) { throw new FeatherException(String.format("Can't inject field %s in %s", field.getName(), target.getClass().getName())); } @@ -202,7 +215,7 @@ private static Object[] params(Provider[] paramProviders) { private static Set append(Set set, Key newKey) { if (set != null && !set.isEmpty()) { - Set appended = new LinkedHashSet<>(set); + Set appended = new LinkedHashSet(set); appended.add(newKey); return appended; } else { @@ -229,7 +242,7 @@ private static Object[][] injectFields(Class target) { private static Set fields(Class type) { Class current = type; - Set fields = new HashSet<>(); + Set fields = new HashSet(); while (!current.equals(Object.class)) { for (Field field : current.getDeclaredFields()) { if (field.isAnnotationPresent(Inject.class)) { @@ -275,7 +288,7 @@ private static Constructor constructor(Key key) { private static Set providers(Class type) { Class current = type; - Set providers = new HashSet<>(); + Set providers = new HashSet(); while (!current.equals(Object.class)) { for (Method method : current.getDeclaredMethods()) { if (method.isAnnotationPresent(Provides.class) && (type.equals(current) || !providerInSubClass(method, providers))) { diff --git a/feather/src/main/java/org/codejargon/feather/Key.java b/feather/src/main/java/org/codejargon/feather/Key.java index 9d726ab..2588fa8 100644 --- a/feather/src/main/java/org/codejargon/feather/Key.java +++ b/feather/src/main/java/org/codejargon/feather/Key.java @@ -1,8 +1,9 @@ package org.codejargon.feather; -import javax.inject.Named; import java.lang.annotation.Annotation; +import javax.inject.Named; + public class Key { final Class type; final Class qualifier; @@ -18,21 +19,21 @@ private Key(Class type, Class qualifier, String name) { * @return Key for a given type */ public static Key of(Class type) { - return new Key<>(type, null, null); + return new Key(type, null, null); } /** * @return Key for a given type and qualifier annotation type */ public static Key of(Class type, Class qualifier) { - return new Key<>(type, qualifier, null); + return new Key(type, qualifier, null); } /** * @return Key for a given type and name (@Named value) */ public static Key of(Class type, String name) { - return new Key<>(type, Named.class, name); + return new Key(type, Named.class, name); } static Key of(Class type, Annotation qualifier) { diff --git a/pom.xml b/pom.xml index e7652c1..60823d4 100644 --- a/pom.xml +++ b/pom.xml @@ -29,8 +29,8 @@ UTF-8 - 1.7 - 1.7 + 1.6 + 1.6 scm:git:https://github.com/zsoltherpai/feather.git @@ -124,8 +124,8 @@ true false - 1.7 - 1.7 + 1.6 + 1.6 @@ -139,8 +139,8 @@ maven-compiler-plugin 3.3 - 1.7 - 1.7 + 1.6 + 1.6