diff --git a/TUTORIAL.md b/TUTORIAL.md index a22e2b5..3a50ae7 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -255,13 +255,13 @@ An application context is defined as follows: ```d class Context : ApplicationContext { - public override void registerDependencies(shared(DependencyContainer) container) { + override void registerDependencies(shared(DependencyContainer) container) { container.register!SomeClass; container.register!(SomeInterface, SomeOtherClass).newInstance(); } @Component - public SomeLibraryClass libraryClass() { + SomeLibraryClass libraryClass() { return new SomeLibraryClass("This class uses a constructor parameter of a built-in type so I have to register it through an application context"); } } @@ -299,12 +299,12 @@ class Context : ApplicationContext { @Inject private SomeOtherClass someOtherClass; - public override void registerDependencies(shared(DependencyContainer) container) { + override void registerDependencies(shared(DependencyContainer) container) { container.register!SomeClass; } @Component - public SomeLibraryClass libraryClass() { + SomeLibraryClass libraryClass() { return new SomeLibraryClass(someClass, someOtherClass); } } @@ -324,7 +324,7 @@ class Context : ApplicationContext { @Component @Prototype // Will create a new instance every time the dependency is resolved. @RegisterByType!SomeInterface // Registers the dependency by the specified super type instead of the return type - public SomeClass someClass() { + SomeClass someClass() { return new SomeClass(); } } diff --git a/example/annotations/app.d b/example/annotations/app.d index 67716f8..7cecdfe 100644 --- a/example/annotations/app.d +++ b/example/annotations/app.d @@ -13,7 +13,7 @@ import std.stdio; import std.conv; class SecurityAuditor { - public void submitAudit() { + void submitAudit() { writeln("Hmmmyes I have received your audit. It is.... adequate."); } } @@ -21,12 +21,12 @@ class SecurityAuditor { class SuperSecurityDevice { private int seed; - public this() { + this() { auto randomGenerator = Random(unpredictableSeed); seed = uniform(0, 999, randomGenerator); } - public string getPassword() { + string getPassword() { return to!string(seed) ~ "t1m3sp13!!:"; } } @@ -38,7 +38,7 @@ class SecurityManager { @Inject @OptionalDependency private SecurityAuditor auditor; - public void doAudit() { + void doAudit() { if (auditor !is null) { auditor.submitAudit(); } else { diff --git a/example/applicationcontext/app.d b/example/applicationcontext/app.d index 4577ed9..d596b6b 100644 --- a/example/applicationcontext/app.d +++ b/example/applicationcontext/app.d @@ -12,17 +12,17 @@ import std.stdio; class TownSquare { @Inject private MarketStall marketStall; - public void makeSound() { + void makeSound() { marketStall.announceGoodsForSale(); } } interface Goods { - public string getGoodsName(); + string getGoodsName(); } class Fish : Goods { - public override string getGoodsName() { + override string getGoodsName() { return "Fish"; } } @@ -34,7 +34,7 @@ class MarketStall { this.goods = goods; } - public void announceGoodsForSale() { + void announceGoodsForSale() { writeln(goods.getGoodsName() ~ " for sale!"); } } @@ -42,12 +42,12 @@ class MarketStall { class ExampleApplicationContext : ApplicationContext { @Inject private Goods goods; - public override void registerDependencies(shared(DependencyContainer) container) { + override void registerDependencies(shared(DependencyContainer) container) { container.register!(Goods, Fish); container.register!TownSquare; } - @Component public MarketStall marketStall() { + @Component MarketStall marketStall() { return new MarketStall(goods); } } diff --git a/example/arraycompletion/app.d b/example/arraycompletion/app.d index e1ddb5e..0a8ee48 100644 --- a/example/arraycompletion/app.d +++ b/example/arraycompletion/app.d @@ -10,23 +10,23 @@ import poodinis; import std.stdio; interface Pie { - public void eat(); + void eat(); } class BlueBerryPie : Pie { - public override void eat() { + override void eat() { writeln("Nom nom nom. I like this one!"); } } class ApplePie : Pie { - public override void eat() { + override void eat() { writeln("Nom nom nom. These aren't real apples..."); } } class CardboardBoxPie : Pie { - public override void eat() { + override void eat() { writeln("Nom nom nom. This... is not a pie."); } } @@ -34,7 +34,7 @@ class CardboardBoxPie : Pie { class PieEater { @Inject private Pie[] pies; - public void eatThemAll() { + void eatThemAll() { foreach (pie; pies) { pie.eat(); } diff --git a/example/constructorinjection/app.d b/example/constructorinjection/app.d index 000c437..663a2af 100644 --- a/example/constructorinjection/app.d +++ b/example/constructorinjection/app.d @@ -15,7 +15,7 @@ class Scheduler { this.calendar = calendar; } - public void scheduleJob() { + void scheduleJob() { calendar.findOpenDate(); } } @@ -32,7 +32,7 @@ class Calendar { this.hardwareClock = hardwareClock; } - public void findOpenDate() { + void findOpenDate() { hardwareClock.doThings(); } } @@ -47,7 +47,7 @@ class HardwareClock { throw new Exception("This constructor should not be used by Poodinis"); } - public void doThings() { + void doThings() { writeln("Things are being done!"); } } diff --git a/example/postconpredest/app.d b/example/postconpredest/app.d index fffd373..9bfe06a 100644 --- a/example/postconpredest/app.d +++ b/example/postconpredest/app.d @@ -10,19 +10,19 @@ import poodinis; import std.stdio; class ADependency { - @PostConstruct public void postConstructor() { + @PostConstruct void postConstructor() { writeln("The dependency is created."); } - public void callMe() { + void callMe() { writeln("The dependency was called."); } } class AClass { - @Inject public ADependency dependency; // Dependencies are autowired before the post-constructor is called. + @Inject ADependency dependency; // Dependencies are autowired before the post-constructor is called. - @PostConstruct public void postConstructor() { + @PostConstruct void postConstructor() { writeln("The class is created."); if (dependency !is null) { writeln("The dependency is autowired."); @@ -31,12 +31,12 @@ class AClass { } } - @PreDestroy public void preDestructor() { + @PreDestroy void preDestructor() { writeln("The class is no longer registered with the container."); } } -public void main() { +void main() { auto container = new shared DependencyContainer(); container.register!(ADependency).onConstructed((Object obj) { writeln("ADependency constructed"); diff --git a/example/qualifiers/app.d b/example/qualifiers/app.d index 53b3164..c8a6f7a 100644 --- a/example/qualifiers/app.d +++ b/example/qualifiers/app.d @@ -10,17 +10,17 @@ import poodinis; import std.stdio; interface Engine { - public void engage(); + void engage(); } class FuelEngine : Engine { - public void engage() { + void engage() { writeln("VROOOOOOM!"); } } class ElectricEngine : Engine { - public void engage() { + void engage() { writeln("hummmmmmmm...."); } } @@ -32,7 +32,7 @@ class HybridCar { @Inject!ElectricEngine private Engine electricEngine; - public void moveAtSpeed(KilometersPerHour speed) { + void moveAtSpeed(KilometersPerHour speed) { if (speed <= 45) { electricEngine.engage(); } else { diff --git a/example/valueinjection/app.d b/example/valueinjection/app.d index 643ce95..c943c4a 100644 --- a/example/valueinjection/app.d +++ b/example/valueinjection/app.d @@ -48,7 +48,7 @@ class HttpServer { @MandatoryValue("http.keep_alive") private int keepAliveTime; // A ResolveException is thrown when the value is not available, default assignments are not used. - public void serve() { + void serve() { writeln(format("Serving pages for %s:%s with max connection count of %s", hostName, port, maxConnections)); } diff --git a/source/poodinis/autowire.d b/source/poodinis/autowire.d index 648dacf..4c97275 100644 --- a/source/poodinis/autowire.d +++ b/source/poodinis/autowire.d @@ -51,7 +51,7 @@ private struct UseMemberType { * --- * class Car { * @Autowire - * public Engine engine; + * Engine engine; * } * --- * @@ -62,10 +62,10 @@ private struct UseMemberType { * * class HybridCar { * @Autowire!FuelEngine - * public Engine fuelEngine; + * Engine fuelEngine; * * @Autowire!ElectricEngine - * public Engine electricEngine; + * Engine electricEngine; * } * --- * The members of an instance of "HybridCar" will now be autowired properly, because the autowire mechanism will @@ -94,7 +94,7 @@ struct OptionalDependency { * class Car { * @Autowire * @AssignNewInstance - * public Antenna antenna; + * Antenna antenna; * } *--- * antenna will always be assigned a new instance of class Antenna. @@ -117,7 +117,7 @@ private void printDebugAutowiredInstance(TypeInfo instanceType, void* instanceAd * * See_Also: Autowire */ -public void autowire(Type)(shared(DependencyContainer) container, Type instance) { +void autowire(Type)(shared(DependencyContainer) container, Type instance) { debug (poodinisVerbose) { printDebugAutowiredInstance(typeid(Type), &instance); } @@ -276,19 +276,19 @@ private void printDebugValueInjection(TypeInfo instanceType, * See_Also: DependencyContainer * Deprecated: Using the global container is undesired. See DependencyContainer.getInstance(). */ -public deprecated void globalAutowire(Type)(Type instance) { +deprecated void globalAutowire(Type)(Type instance) { DependencyContainer.getInstance().autowire(instance); } class AutowiredRegistration(RegistrationType : Object) : Registration { private shared(DependencyContainer) container; - public this(TypeInfo registeredType, InstanceFactory instanceFactory, + this(TypeInfo registeredType, InstanceFactory instanceFactory, shared(DependencyContainer) originatingContainer) { super(registeredType, typeid(RegistrationType), instanceFactory, originatingContainer); } - public override Object getInstance( + override Object getInstance( InstantiationContext context = new AutowireInstantiationContext()) { enforce(!(originatingContainer is null), "The registration's originating container is null. There is no way to resolve autowire dependencies."); @@ -324,5 +324,5 @@ class AutowiredRegistration(RegistrationType : Object) : Registration { } class AutowireInstantiationContext : InstantiationContext { - public bool autowireInstance = true; + bool autowireInstance = true; } diff --git a/source/poodinis/container.d b/source/poodinis/container.d index 883ba42..2ef158c 100644 --- a/source/poodinis/container.d +++ b/source/poodinis/container.d @@ -56,7 +56,7 @@ class RegistrationException : Exception { /** * Options which influence the process of registering dependencies */ -public enum RegistrationOption { +enum RegistrationOption { none = 0, /** * Prevent a concrete type being registered on itself. With this option you will always need @@ -68,7 +68,7 @@ public enum RegistrationOption { /** * Options which influence the process of resolving dependencies */ -public enum ResolveOption { +enum ResolveOption { none = 0, /** * Registers the type you're trying to resolve before returning it. @@ -146,7 +146,7 @@ synchronized class DependencyContainer { * * See_Also: singleInstance, newInstance, existingInstance */ - public Registration register(ConcreteType)(RegistrationOption options = RegistrationOption.none) { + Registration register(ConcreteType)(RegistrationOption options = RegistrationOption.none) { return register!(ConcreteType, ConcreteType)(options); } @@ -167,7 +167,7 @@ synchronized class DependencyContainer { * * See_Also: singleInstance, newInstance, existingInstance, RegistrationOption */ - public Registration register(SuperType, ConcreteType: + Registration register(SuperType, ConcreteType: SuperType)(RegistrationOption options = RegistrationOption.none) if (!is(ConcreteType == struct)) { TypeInfo registeredType = typeid(SuperType); @@ -271,7 +271,7 @@ synchronized class DependencyContainer { * --- * You need to use the resolve method which allows you to specify a qualifier. */ - public RegistrationType resolve(RegistrationType)( + RegistrationType resolve(RegistrationType)( ResolveOption resolveOptions = ResolveOption.none) if (!is(RegistrationType == struct)) { return resolve!(RegistrationType, RegistrationType)(resolveOptions); @@ -303,7 +303,7 @@ synchronized class DependencyContainer { * container.resolve!(Animal, Dog); * --- */ - public QualifierType resolve(RegistrationType, QualifierType: + QualifierType resolve(RegistrationType, QualifierType: RegistrationType)(ResolveOption resolveOptions = ResolveOption.none) if (!is(QualifierType == struct)) { TypeInfo resolveType = typeid(RegistrationType); @@ -381,7 +381,7 @@ synchronized class DependencyContainer { * Animal[] animals = container.resolveAll!Animal; * --- */ - public RegistrationType[] resolveAll(RegistrationType)( + RegistrationType[] resolveAll(RegistrationType)( ResolveOption resolveOptions = ResolveOption.none) { RegistrationType[] instances; TypeInfo resolveType = typeid(RegistrationType); @@ -435,7 +435,7 @@ synchronized class DependencyContainer { /** * Clears all dependency registrations managed by this container. */ - public void clearAllRegistrations() { + void clearAllRegistrations() { foreach (registrationsOfType; registrations) { callPreDestructorsOfRegistrations(registrationsOfType); } @@ -452,7 +452,7 @@ synchronized class DependencyContainer { * container.removeRegistration!Animal; * --- */ - public void removeRegistration(RegistrationType)() { + void removeRegistration(RegistrationType)() { auto registrationsOfType = *(typeid(RegistrationType) in registrations); callPreDestructorsOfRegistrations(registrationsOfType); registrations.remove(typeid(RegistrationType)); @@ -470,28 +470,28 @@ synchronized class DependencyContainer { /** * Apply persistent registration options which will be used everytime register() is called. */ - public void setPersistentRegistrationOptions(RegistrationOption options) { + void setPersistentRegistrationOptions(RegistrationOption options) { persistentRegistrationOptions = options; } /** * Unsets all applied persistent registration options */ - public void unsetPersistentRegistrationOptions() { + void unsetPersistentRegistrationOptions() { persistentRegistrationOptions = RegistrationOption.none; } /** * Apply persistent resolve options which will be used everytime resolve() is called. */ - public void setPersistentResolveOptions(ResolveOption options) { + void setPersistentResolveOptions(ResolveOption options) { persistentResolveOptions = options; } /** * Unsets all applied persistent resolve options */ - public void unsetPersistentResolveOptions() { + void unsetPersistentResolveOptions() { persistentResolveOptions = ResolveOption.none; } diff --git a/source/poodinis/context.d b/source/poodinis/context.d index c37e06e..f089613 100644 --- a/source/poodinis/context.d +++ b/source/poodinis/context.d @@ -21,7 +21,7 @@ import poodinis.autowire : autowire; import std.traits : hasUDA, ReturnType; class ApplicationContext { - public void registerDependencies(shared(DependencyContainer) container) { + void registerDependencies(shared(DependencyContainer) container) { } } @@ -54,7 +54,7 @@ struct Prototype { * It is mostly used for dependencies which come from an external library or when you don't * want to use annotations to set-up dependencies in your classes. */ -public void registerContext(Context : ApplicationContext)(shared(DependencyContainer) container) { +void registerContext(Context : ApplicationContext)(shared(DependencyContainer) container) { auto context = new Context(); context.registerDependencies(container); context.registerContextComponents(container); @@ -62,7 +62,7 @@ public void registerContext(Context : ApplicationContext)(shared(DependencyConta autowire(container, context); } -public void registerContextComponents(ApplicationContextType : ApplicationContext)( +void registerContextComponents(ApplicationContextType : ApplicationContext)( ApplicationContextType context, shared(DependencyContainer) container) { foreach (memberName; __traits(allMembers, ApplicationContextType)) { foreach (overload; __traits(getOverloads, ApplicationContextType, memberName)) { diff --git a/source/poodinis/factory.d b/source/poodinis/factory.d index 4526a62..82d6022 100644 --- a/source/poodinis/factory.d +++ b/source/poodinis/factory.d @@ -49,7 +49,7 @@ class InstanceFactory { factoryParameters = InstanceFactoryParameters(); } - public @property void factoryParameters(InstanceFactoryParameters factoryParameters) { + @property void factoryParameters(InstanceFactoryParameters factoryParameters) { if (factoryParameters.factoryMethod is null) { factoryParameters.factoryMethod = &this.createInstance; } @@ -62,11 +62,11 @@ class InstanceFactory { _factoryParameters = factoryParameters; } - public @property InstanceFactoryParameters factoryParameters() { + @property InstanceFactoryParameters factoryParameters() { return _factoryParameters; } - public Object getInstance() { + Object getInstance() { if (_factoryParameters.createsSingleton && instance !is null) { debug (poodinisVerbose) { printDebugUseExistingInstance(); diff --git a/source/poodinis/imports.d b/source/poodinis/imports.d index b2eb3c3..b3ca2a8 100644 --- a/source/poodinis/imports.d +++ b/source/poodinis/imports.d @@ -14,7 +14,7 @@ module poodinis.imports; import std.meta : staticIndexOf; import std.traits : moduleName, TemplateArgsOf, isBuiltinType, isType; -public static string createImportsString(Type, ParentTypeList...)() { +static string createImportsString(Type, ParentTypeList...)() { string imports = `import ` ~ moduleName!Type ~ `;`; static if (__traits(compiles, TemplateArgsOf!Type)) { foreach (TemplateArgType; TemplateArgsOf!Type) { diff --git a/source/poodinis/registration.d b/source/poodinis/registration.d index bc02843..e5c244c 100644 --- a/source/poodinis/registration.d +++ b/source/poodinis/registration.d @@ -25,23 +25,23 @@ class Registration { private InstanceFactory _instanceFactory; private void delegate() _preDestructor; - public @property registeredType() { + @property registeredType() { return _registeredType; } - public @property instanceType() { + @property instanceType() { return _instanceType; } - public @property originatingContainer() { + @property originatingContainer() { return _originatingContainer; } - public @property instanceFactory() { + @property instanceFactory() { return _instanceFactory; } - public @property preDestructor() { + @property preDestructor() { return _preDestructor; } @@ -57,7 +57,7 @@ class Registration { this._instanceFactory = instanceFactory; } - public Object getInstance(InstantiationContext context = new InstantiationContext()) { + Object getInstance(InstantiationContext context = new InstantiationContext()) { if (linkedRegistration !is null) { return linkedRegistration.getInstance(context); } @@ -70,7 +70,7 @@ class Registration { return instanceFactory.getInstance(); } - public Registration linkTo(Registration registration) { + Registration linkTo(Registration registration) { this.linkedRegistration = registration; return this; } @@ -95,7 +95,7 @@ private void setFactoryParameters(Registration registration, InstanceFactoryPara * * This is not a registration scope. Typically used by Poodinis internally only. */ -public Registration initializeFactoryType(Registration registration) { +Registration initializeFactoryType(Registration registration) { auto params = registration.copyFactoryParameters(); params.instanceType = registration.instanceType; registration.setFactoryParameters(params); @@ -107,7 +107,7 @@ public Registration initializeFactoryType(Registration registration) { * * Effectively makes the given registration a singleton. */ -public Registration singleInstance(Registration registration) { +Registration singleInstance(Registration registration) { auto params = registration.copyFactoryParameters(); params.createsSingleton = CreatesSingleton.yes; registration.setFactoryParameters(params); @@ -117,7 +117,7 @@ public Registration singleInstance(Registration registration) { /** * Scopes registrations to return a new instance every time the given registration is resolved. */ -public Registration newInstance(Registration registration) { +Registration newInstance(Registration registration) { auto params = registration.copyFactoryParameters(); params.createsSingleton = CreatesSingleton.no; params.existingInstance = null; @@ -128,7 +128,7 @@ public Registration newInstance(Registration registration) { /** * Scopes registrations to return the given instance every time the given registration is resolved. */ -public Registration existingInstance(Registration registration, Object instance) { +Registration existingInstance(Registration registration, Object instance) { auto params = registration.copyFactoryParameters(); params.createsSingleton = CreatesSingleton.yes; params.existingInstance = instance; @@ -139,7 +139,7 @@ public Registration existingInstance(Registration registration, Object instance) /** * Scopes registrations to create new instances using the given initializer delegate. */ -public Registration initializedBy(T)(Registration registration, T delegate() initializer) +Registration initializedBy(T)(Registration registration, T delegate() initializer) if (is(T == class) || is(T == interface)) { auto params = registration.copyFactoryParameters(); params.createsSingleton = CreatesSingleton.no; @@ -151,7 +151,7 @@ public Registration initializedBy(T)(Registration registration, T delegate() ini /** * Scopes registrations to create a new instance using the given initializer delegate. On subsequent resolves the same instance is returned. */ -public Registration initializedOnceBy(T : Object)(Registration registration, T delegate() initializer) { +Registration initializedOnceBy(T : Object)(Registration registration, T delegate() initializer) { auto params = registration.copyFactoryParameters(); params.createsSingleton = CreatesSingleton.yes; params.factoryMethod = () => cast(Object) initializer(); @@ -159,7 +159,7 @@ public Registration initializedOnceBy(T : Object)(Registration registration, T d return registration; } -public string toConcreteTypeListString(Registration[] registrations) { +string toConcreteTypeListString(Registration[] registrations) { auto concreteTypeListString = ""; foreach (registration; registrations) { if (concreteTypeListString.length > 0) { diff --git a/source/poodinis/valueinjection.d b/source/poodinis/valueinjection.d index c0ce9ac..8430ec9 100644 --- a/source/poodinis/valueinjection.d +++ b/source/poodinis/valueinjection.d @@ -101,7 +101,7 @@ struct MandatoryValue { * Examples: * --- * class MyIntInjector : ValueInjector!int { - * public override int get(string key) { ... } + * override int get(string key) { ... } * } * * // In order to make the container use your injector, register it by interface: diff --git a/test/poodinis/testclasses.d b/test/poodinis/testclasses.d index e5ddab4..fcd5d34 100644 --- a/test/poodinis/testclasses.d +++ b/test/poodinis/testclasses.d @@ -15,7 +15,7 @@ version (unittest) { } class ComponentB { - public @Inject ComponentA componentA; + @Inject ComponentA componentA; } interface InterfaceA { @@ -25,10 +25,10 @@ version (unittest) { } class ComponentD { - public @Inject InterfaceA componentC = null; + @Inject InterfaceA componentC = null; private @Inject InterfaceA _privateComponentC = null; - public InterfaceA privateComponentC() { + InterfaceA privateComponentC() { return _privateComponentC; } } @@ -37,15 +37,15 @@ version (unittest) { }; class ComponentE { - @DummyAttribute public ComponentC componentC; + @DummyAttribute ComponentC componentC; } class ComponentDeclarationCocktail { alias noomer = int; - @Inject public ComponentA componentA; + @Inject ComponentA componentA; - public void doesNothing() { + void doesNothing() { } ~this() { @@ -59,40 +59,40 @@ version (unittest) { } class MonkeyShine { - @Inject!ComponentX public InterfaceA component; + @Inject!ComponentX InterfaceA component; } class BootstrapBootstrap { - @Inject!ComponentX public InterfaceA componentX; + @Inject!ComponentX InterfaceA componentX; - @Inject!ComponentC public InterfaceA componentC; + @Inject!ComponentC InterfaceA componentC; } class LordOfTheComponents { - @Inject public InterfaceA[] components; + @Inject InterfaceA[] components; } class ComponentCharlie { - @Inject @AssignNewInstance public ComponentA componentA; + @Inject @AssignNewInstance ComponentA componentA; } class OuttaTime { - @Inject @OptionalDependency public InterfaceA interfaceA; + @Inject @OptionalDependency InterfaceA interfaceA; - @Inject @OptionalDependency public ComponentA componentA; + @Inject @OptionalDependency ComponentA componentA; - @Inject @OptionalDependency public ComponentC[] componentCs; + @Inject @OptionalDependency ComponentC[] componentCs; } class ValuedClass { @Value("values.int") - public int intValue; + int intValue; - @Inject public ComponentA unrelated; + @Inject ComponentA unrelated; } class TestInjector : ValueInjector!int { - public override int get(string key) { + override int get(string key) { assert(key == "values.int"); return 8; } @@ -105,7 +105,7 @@ version (unittest) { } class TestClassDeux : TestInterface { - @Inject public UnrelatedClass unrelated; + @Inject UnrelatedClass unrelated; } class UnrelatedClass { @@ -121,46 +121,46 @@ version (unittest) { } class ComponentClass { - @Inject public AutowiredClass autowiredClass; + @Inject AutowiredClass autowiredClass; } class ComponentCat { - @Inject public ComponentMouse mouse; + @Inject ComponentMouse mouse; } class ComponentMouse { - @Inject public ComponentCat cat; + @Inject ComponentCat cat; } class Eenie { - @Inject public Meenie meenie; + @Inject Meenie meenie; } class Meenie { - @Inject public Moe moe; + @Inject Moe moe; } class Moe { - @Inject public Eenie eenie; + @Inject Eenie eenie; } class Ittie { - @Inject public Bittie bittie; + @Inject Bittie bittie; } class Bittie { - @Inject public Bunena banana; + @Inject Bunena banana; } class Bunena { - @Inject public Bittie bittie; + @Inject Bittie bittie; } interface SuperInterface { } class SuperImplementation : SuperInterface { - @Inject public Bunena banana; + @Inject Bunena banana; } interface Color { @@ -173,28 +173,28 @@ version (unittest) { } class Spiders { - @Inject public TestInterface testMember; + @Inject TestInterface testMember; } class Recursive { - @Inject public Recursive recursive; + @Inject Recursive recursive; } class Moolah { } class Wants { - @Inject public Moolah moolah; + @Inject Moolah moolah; } class John { - @Inject public Wants wants; + @Inject Wants wants; } class Cocktail { - @Inject public Moolah moolah; + @Inject Moolah moolah; - public Red red; + Red red; this(Red red) { this.red = red; @@ -202,7 +202,7 @@ version (unittest) { } class Wallpaper { - public Color color; + Color color; this(Color color) { this.color = color; @@ -240,9 +240,9 @@ version (unittest) { } class PostConstructionDependency { - public bool postConstructWasCalled = false; + bool postConstructWasCalled = false; - @PostConstruct public void callMeMaybe() { + @PostConstruct void callMeMaybe() { postConstructWasCalled = true; } } @@ -255,9 +255,9 @@ version (unittest) { } class ButThereWontBe : ThereWillBePostConstruction { - public bool postConstructWasCalled = false; + bool postConstructWasCalled = false; - public override void constructIt() { + override void constructIt() { postConstructWasCalled = true; } } @@ -268,16 +268,16 @@ version (unittest) { @Value("") private int theNumber = 1; - @PostConstruct public void doIt() { + @PostConstruct void doIt() { assert(theNumber == 8783); assert(dependency !is null); } } class PreDestroyerOfFates { - public bool preDestroyWasCalled = false; + bool preDestroyWasCalled = false; - @PreDestroy public void callMeMaybe() { + @PreDestroy void callMeMaybe() { preDestroyWasCalled = true; } } @@ -297,7 +297,7 @@ version (unittest) { } class Banana { - public string color; + string color; this(string color) { this.color = color; @@ -308,19 +308,19 @@ version (unittest) { } class Pear : Fruit { - public override string getShape() { + override string getShape() { return "Pear shaped"; } } class Rabbit : Animal { - public override string getYell() { + override string getYell() { return "Squeeeeeel"; } } class Wolf : Animal { - public override string getYell() { + override string getYell() { return "Wooooooooooo"; } } @@ -332,7 +332,7 @@ version (unittest) { } class ClassWrapper { - public Object someClass; + Object someClass; this(Object someClass) { this.someClass = someClass; @@ -340,7 +340,7 @@ version (unittest) { } class ClassWrapperWrapper { - public ClassWrapper wrapper; + ClassWrapper wrapper; this(ClassWrapper wrapper) { this.wrapper = wrapper; @@ -348,11 +348,11 @@ version (unittest) { } class SimpleContext : ApplicationContext { - public override void registerDependencies(shared(DependencyContainer) container) { + override void registerDependencies(shared(DependencyContainer) container) { container.register!CakeChart; } - @Component public Apple apple() { + @Component Apple apple() { return new Apple(); } } @@ -363,15 +363,15 @@ version (unittest) { @Inject protected ClassWrapper classWrapper; - public override void registerDependencies(shared(DependencyContainer) container) { + override void registerDependencies(shared(DependencyContainer) container) { container.register!Apple; } - @Component public ClassWrapper wrapper() { + @Component ClassWrapper wrapper() { return new ClassWrapper(apple); } - @Component public ClassWrapperWrapper wrapperWrapper() { + @Component ClassWrapperWrapper wrapperWrapper() { return new ClassWrapperWrapper(classWrapper); } @@ -381,47 +381,47 @@ version (unittest) { @Inject private Apple apple; - @Component public ClassWrapper wrapper() { + @Component ClassWrapper wrapper() { return new ClassWrapper(apple); } } class TestContext : ApplicationContext { - @Component public Banana banana() { + @Component Banana banana() { return new Banana("Yellow"); } - public Apple apple() { + Apple apple() { return new Apple(); } - @Component @RegisterByType!Fruit public Pear pear() { + @Component @RegisterByType!Fruit Pear pear() { return new Pear(); } - @Component @RegisterByType!Animal public Rabbit rabbit() { + @Component @RegisterByType!Animal Rabbit rabbit() { return new Rabbit(); } - @Component @RegisterByType!Animal public Wolf wolf() { + @Component @RegisterByType!Animal Wolf wolf() { return new Wolf(); } - @Component @Prototype public PieChart pieChart() { + @Component @Prototype PieChart pieChart() { return new PieChart(); } } class TestImplementation : TestInterface { - public string someContent = ""; + string someContent = ""; } class SomeOtherClassThen { } class ClassWithConstructor { - public TestImplementation testImplementation; + TestImplementation testImplementation; this(TestImplementation testImplementation) { this.testImplementation = testImplementation; @@ -429,8 +429,8 @@ version (unittest) { } class ClassWithMultipleConstructors { - public SomeOtherClassThen someOtherClassThen; - public TestImplementation testImplementation; + SomeOtherClassThen someOtherClassThen; + TestImplementation testImplementation; this(SomeOtherClassThen someOtherClassThen) { this.someOtherClassThen = someOtherClassThen; @@ -443,8 +443,8 @@ version (unittest) { } class ClassWithConstructorWithMultipleParameters { - public SomeOtherClassThen someOtherClassThen; - public TestImplementation testImplementation; + SomeOtherClassThen someOtherClassThen; + TestImplementation testImplementation; this(SomeOtherClassThen someOtherClassThen, TestImplementation testImplementation) { this.someOtherClassThen = someOtherClassThen; @@ -453,7 +453,7 @@ version (unittest) { } class ClassWithPrimitiveConstructor { - public SomeOtherClassThen someOtherClassThen; + SomeOtherClassThen someOtherClassThen; this(string willNotBePicked) { } @@ -464,7 +464,7 @@ version (unittest) { } class ClassWithEmptyConstructor { - public SomeOtherClassThen someOtherClassThen; + SomeOtherClassThen someOtherClassThen; this() { } @@ -480,7 +480,7 @@ version (unittest) { } class ClassWithStructConstructor { - public SomeOtherClassThen someOtherClassThen; + SomeOtherClassThen someOtherClassThen; this(Thing willNotBePicked) { } @@ -522,58 +522,58 @@ version (unittest) { } class IntInjector : ValueInjector!int { - public override int get(string key) { + override int get(string key) { assert(key == "conf.stuffs"); return 364; } } class StringInjector : ValueInjector!string { - public override string get(string key) { + override string get(string key) { assert(key == "conf.name"); return "Le Chef"; } } class ThingInjector : ValueInjector!Thing { - public override Thing get(string key) { + override Thing get(string key) { assert(key == "conf.thing"); return Thing(8899); } } class DefaultIntInjector : ValueInjector!int { - public override int get(string key) { + override int get(string key) { throw new ValueNotAvailableException(key); } } class MandatoryAvailableIntInjector : ValueInjector!int { - public override int get(string key) { + override int get(string key) { return 7466; } } class MandatoryUnavailableIntInjector : ValueInjector!int { - public override int get(string key) { + override int get(string key) { throw new ValueNotAvailableException(key); } } class DependencyInjectedIntInjector : ValueInjector!int { - @Inject public Dependency dependency; + @Inject Dependency dependency; - public override int get(string key) { + override int get(string key) { return 2345; } } class CircularIntInjector : ValueInjector!int { - @Inject public ValueInjector!int dependency; + @Inject ValueInjector!int dependency; private int count = 0; - public override int get(string key) { + override int get(string key) { count += 1; if (count >= 3) { return count; @@ -584,9 +584,9 @@ version (unittest) { class ValueInjectedIntInjector : ValueInjector!int { @Value("five") - public int count = 0; + int count = 0; - public override int get(string key) { + override int get(string key) { if (key == "five") { return 5; } @@ -596,9 +596,9 @@ version (unittest) { } class DependencyValueInjectedIntInjector : ValueInjector!int { - @Inject public ConfigWithDefaults config; + @Inject ConfigWithDefaults config; - public override int get(string key) { + override int get(string key) { if (key == "conf.missing") { return 8899; } @@ -620,7 +620,7 @@ version (unittest) { } class ClassWithTemplatedConstructorArg(T) { - public TemplatedComponent!T dependency; + TemplatedComponent!T dependency; this(TemplatedComponent!T assignedDependency) { this.dependency = assignedDependency; @@ -641,17 +641,17 @@ version (unittest) { class AutowiredMethod { @Inject - public int lala() { + int lala() { return 42; } @Inject - public int lala(int valla) { + int lala(int valla) { return valla; } } class WithAutowireAttribute { - public @Autowire ComponentA componentA; + @Autowire ComponentA componentA; } } diff --git a/test/poodinis/valueinjectiontest.d b/test/poodinis/valueinjectiontest.d index b74d01e..a8182bd 100644 --- a/test/poodinis/valueinjectiontest.d +++ b/test/poodinis/valueinjectiontest.d @@ -17,7 +17,7 @@ version (unittest) { } class LocalStructInjector : ValueInjector!LocalStruct { - public override LocalStruct get(string key) { + override LocalStruct get(string key) { auto data = LocalStruct(true); return data; } @@ -25,7 +25,7 @@ version (unittest) { class LocalClassWithStruct { @Value("") - public LocalStruct localStruct; + LocalStruct localStruct; } // Test injection of values