Browse Source

Remove discouraged non-functional factory registrations

master
Paweł Płazieński 6 months ago
parent
commit
37acfe73c0
3 changed files with 24 additions and 23 deletions
  1. +12
    -6
      src/main/java/org/perfectable/injection/Configuration.java
  2. +12
    -5
      src/main/java/org/perfectable/injection/registration/Registration.java
  3. +0
    -12
      src/main/java/org/perfectable/injection/registration/StandardRegistration.java

+ 12
- 6
src/main/java/org/perfectable/injection/Configuration.java View File

@@ -8,6 +8,7 @@ import org.perfectable.injection.replacement.Replacement;
import org.perfectable.injection.scope.Scope;

import java.lang.annotation.Annotation;
import java.util.Set;
import javax.inject.Provider;

public interface Configuration {
@@ -42,18 +43,23 @@ public interface Configuration {
register(Registration.factory(factory));
}

default <P, F> void registerFactory(Class<P> productType, Class<F> factoryType, Factory.Single<P, F> factory) {
register(Registration.factory(productType, factoryType, factory));
default <P, F> void registerFactory(Class<P> productType, Factory.Single<P, F> factory,
Class<F> factoryArgumentClass, Set<? extends Annotation> argumentQualifiers) {
register(Registration.factory(productType, factory, factoryArgumentClass, argumentQualifiers));
}

default <P, F1, F2> void registerFactory(Factory.Double.Functional<P, F1, F2> factory) {
register(Registration.factory(factory));
}

default <P, F1, F2> void registerFactory(Class<P> productType,
Class<F1> factoryFirstType, Class<F2> factorySecondType,
Factory.Double<P, F1, F2> factory) {
register(Registration.factory(productType, factoryFirstType, factorySecondType, factory));
@SuppressWarnings("ParameterNumber")
default <P, F1, F2> void registerFactory(Class<P> productType, Factory.Double<P, F1, F2> factory,
Class<F1> firstArgumentType,
Set<? extends Annotation> firstArgumentQualifiers,
Class<F2> secondArgumentType,
Set<? extends Annotation> secondArgumentQualifiers) {
register(Registration.factory(productType, factory, firstArgumentType, firstArgumentQualifiers,
secondArgumentType, secondArgumentQualifiers));
}

void addScope(Class<? extends Annotation> annotation, Scope scope);


+ 12
- 5
src/main/java/org/perfectable/injection/registration/Registration.java View File

@@ -3,6 +3,7 @@ package org.perfectable.injection.registration;
import org.perfectable.introspection.AnnotationBuilder;

import java.lang.annotation.Annotation;
import java.util.Set;
import javax.inject.Named;
import javax.inject.Provider;

@@ -35,18 +36,24 @@ public interface Registration {
return StandardRegistration.forFactory(factory);
}

static <P, F> Registration factory(Class<P> productType, Class<F> factoryClass, Factory.Single<P, F> factory) {
return StandardRegistration.forFactory(productType, factoryClass, factory);
static <P, F> Registration factory(Class<P> productType, Factory.Single<P, F> factory,
Class<F> factoryArgumentClass, Set<? extends Annotation> argumentQualifiers) {
return StandardRegistration.forFactory(productType, factory, factoryArgumentClass, argumentQualifiers);
}

static <P, F1, F2> Registration factory(Factory.Double.Functional<P, F1, F2> factory) {
return StandardRegistration.forFactory(factory);
}

@SuppressWarnings("ParameterNumber")
static <P, F1, F2> Registration factory(Class<P> productType,
Class<F1> factoryFirstClass, Class<F2> factorySecondClass,
Factory.Double<P, F1, F2> factory) {
return StandardRegistration.forFactory(productType, factoryFirstClass, factorySecondClass, factory);
Factory.Double<P, F1, F2> factory,
Class<F1> firstArgumentClass,
Set<? extends Annotation> firstArgumentQualifiers,
Class<F2> secondArgumentClass,
Set<? extends Annotation> secondArgumentQualifiers) {
return StandardRegistration.forFactory(productType, factory, firstArgumentClass, firstArgumentQualifiers,
secondArgumentClass, secondArgumentQualifiers);
}

default Registration with(Annotation annotation) {


+ 0
- 12
src/main/java/org/perfectable/injection/registration/StandardRegistration.java View File

@@ -47,11 +47,6 @@ public final class StandardRegistration<T> implements Registration {
return new StandardRegistration<>(createdClass, initializator);
}

public static <P, F> StandardRegistration<P> forFactory(Class<P> productType, Class<F> argumentClass,
Factory.Single<P, F> factory) {
return forFactory(productType, factory, argumentClass, ImmutableSet.of());
}

public static <P, F> StandardRegistration<P> forFactory(Class<P> productType, Factory.Single<P, F> factory,
Class<F> argumentClass,
Set<? extends Annotation> argumentQualifiers) {
@@ -70,13 +65,6 @@ public final class StandardRegistration<T> implements Registration {
return new StandardRegistration<>(createdClass, initializator);
}

public static <P, F1, F2> StandardRegistration<P> forFactory(Class<P> productType, Class<F1> factoryFirstClass,
Class<F2> factorySecondClass,
Factory.Double<P, F1, F2> factory) {
return forFactory(productType, factory, factoryFirstClass, ImmutableSet.of(),
factorySecondClass, ImmutableSet.of());
}

@SuppressWarnings("ParameterNumber")
public static <P, F1, F2> StandardRegistration<P> forFactory(Class<P> productType,
Factory.Double<P, F1, F2> factory,


Loading…
Cancel
Save