if (processor != null) {
if (processor.hasDefault()) {
return callback.inject(point, processor.getDefault(), result);
}
}
Default defaultAnnotation = point.getAnnotation(Default.class);
if (defaultAnnotation == null) {
return false;
}
type = mapPrimitiveClasses(type);
Object value = null;
if (type instanceof Class) {
Class<?> injectedClass = (Class<?>) type;
if (injectedClass.isArray()) {
Class<?> componentType = injectedClass.getComponentType();
if (componentType == String.class) {
value = defaultAnnotation.values();
} else if (componentType == Integer.TYPE) {
value = defaultAnnotation.intValues();
} else if (componentType == Integer.class) {
value = ArrayUtils.toObject(defaultAnnotation.intValues());
} else if (componentType == Long.TYPE) {
value = defaultAnnotation.longValues();
} else if (componentType == Long.class) {
value = ArrayUtils.toObject(defaultAnnotation.longValues());
} else if (componentType == Boolean.TYPE) {
value = defaultAnnotation.booleanValues();
} else if (componentType == Boolean.class) {
value = ArrayUtils.toObject(defaultAnnotation.booleanValues());
} else if (componentType == Short.TYPE) {
value = defaultAnnotation.shortValues();
} else if (componentType == Short.class) {
value = ArrayUtils.toObject(defaultAnnotation.shortValues());
} else if (componentType == Float.TYPE) {
value = defaultAnnotation.floatValues();
} else if (componentType == Float.class) {
value = ArrayUtils.toObject(defaultAnnotation.floatValues());
} else if (componentType == Double.TYPE) {
value = defaultAnnotation.doubleValues();
} else if (componentType == Double.class) {
value = ArrayUtils.toObject(defaultAnnotation.doubleValues());
} else {
log.warn("Default values for {} are not supported", componentType);
return false;
}
} else {
if (injectedClass == String.class) {
value = defaultAnnotation.values().length == 0 ? "" : defaultAnnotation.values()[0];
} else if (injectedClass == Integer.class) {
value = defaultAnnotation.intValues().length == 0 ? 0 : defaultAnnotation.intValues()[0];
} else if (injectedClass == Long.class) {
value = defaultAnnotation.longValues().length == 0 ? 0l : defaultAnnotation.longValues()[0];
} else if (injectedClass == Boolean.class) {
value = defaultAnnotation.booleanValues().length == 0 ? false : defaultAnnotation.booleanValues()[0];
} else if (injectedClass == Short.class) {
value = defaultAnnotation.shortValues().length == 0 ? ((short) 0) : defaultAnnotation.shortValues()[0];
} else if (injectedClass == Float.class) {
value = defaultAnnotation.floatValues().length == 0 ? 0f : defaultAnnotation.floatValues()[0];
} else if (injectedClass == Double.class) {
value = defaultAnnotation.doubleValues().length == 0 ? 0d : defaultAnnotation.doubleValues()[0];
} else {
log.warn("Default values for {} are not supported", injectedClass);
return false;
}
}