Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop-modules' into develop-mo…
Browse files Browse the repository at this point in the history
…dules

# Conflicts:
#
generator/src/main/java/com/speedment/generator/internal/component/CodeG
enerationComponentImpl.java
#
maven-plugin/src/main/java/com/speedment/maven/AbstractSpeedmentMojo.jav
a
  • Loading branch information
minborg committed Aug 23, 2016
1 parent 21c02d5 commit 2cf0cff
Show file tree
Hide file tree
Showing 61 changed files with 1,219 additions and 404 deletions.
@@ -0,0 +1,54 @@
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.common.injector;

import static java.util.Objects.requireNonNull;
import java.util.stream.Stream;

/**
*
* @author Per Minborg
*/
@FunctionalInterface
public interface InjectBundle {

/**
* Returns a Stream of classes that are to be provided to an Injector.
*
* @return a Stream of classes that are to be provided to an Injector
*/
Stream<Class<?>> injectables();

static InjectBundle empty() {
return () -> Stream.empty();
}

static InjectBundle of(Class<?>... classes) {
requireNonNull(classes);
return () -> Stream.of(classes);
}

default InjectBundle andThen(InjectBundle next) {
requireNonNull(next);
return () -> Stream.concat(injectables(), next.injectables());
}

default InjectBundle andThen(Class<?> nextClass) {
requireNonNull(nextClass);
return andThen(of(nextClass));
}
}
Expand Up @@ -114,11 +114,15 @@ static Builder builder() {
interface Builder { interface Builder {


/** /**
* Appends one or multiple classes that can be automatically dependency * Appends a class that can be automatically dependency
* injected into other classes to the builder. Classes can be appended in * injected into other classes to the builder. Classes can be appended in
* any order. The final injection order will be determined once the * any order. The final injection order will be determined once the
* {@link #build()}-method is called. * {@link #build()}-method is called.
* <p> * <p>
* If a class has already been passed as injectable with the same InjectorKey,
* the previous one will be replaced by this new one. The old one will
* never be instantiated.
* <p>
* This method will not replace any previous injectables. * This method will not replace any previous injectables.
* *
* @param injectableType the type that should be injectable * @param injectableType the type that should be injectable
Expand All @@ -127,15 +131,15 @@ interface Builder {
* @throws NoDefaultConstructorException if the specified type does not * @throws NoDefaultConstructorException if the specified type does not
* have a default constructor. * have a default constructor.
*/ */
Builder canInject(Class<?> injectableType) throws NoDefaultConstructorException; Builder put(Class<?> injectableType) throws NoDefaultConstructorException;


/** /**
* Appends one or multiple classes that can be automatically dependency * Appends a class that can be automatically dependency
* injected into other classes to the builder. Classes can be appended in * injected into other classes to the builder. Classes can be appended in
* any order. The final injection order will be determined once the * any order. The final injection order will be determined once the
* {@link #build()}-method is called. * {@link #build()}-method is called.
* <p> * <p>
* If a class has already been passed as injectibale with the same key, * If a class has already been passed as injectable with the same key,
* the previous one will be replaced by this new one. The old one will * the previous one will be replaced by this new one. The old one will
* never be instantiated. * never be instantiated.
* *
Expand All @@ -146,7 +150,26 @@ interface Builder {
* @throws NoDefaultConstructorException if the specified type does not * @throws NoDefaultConstructorException if the specified type does not
* have a default constructor. * have a default constructor.
*/ */
Builder canInject(String key, Class<?> injectableType) throws NoDefaultConstructorException; Builder put(String key, Class<?> injectableType) throws NoDefaultConstructorException;


/**
* Puts one or multiple classes contained in an InjectBundle that can
* be automatically dependency injected into other classes to the builder.
* Classes can be appended in any order. The final injection order will
* be determined once the {@link #build()}-method is called.
* <p>
* If an injectable class has already been passed as injectable with the same key,
* the previous one will be replaced by this new one. The old one will
* never be instantiated.
*
* @param bundleClass containing the injectable classes that shall be appended
* @return a reference to this builder
*
* @throws NoDefaultConstructorException if the specified type does not
* have a default constructor.
*/
Builder putInBundle(Class<? extends InjectBundle> bundleClass) throws NoDefaultConstructorException;


/** /**
* Overrides a particular configuration parameter in the config file * Overrides a particular configuration parameter in the config file
Expand All @@ -156,7 +179,7 @@ interface Builder {
* @param value the new value * @param value the new value
* @return a reference to this builder * @return a reference to this builder
*/ */
Builder withParam(String key, String value); Builder putParam(String key, String value);


/** /**
* Sets the location of the configuration file. * Sets the location of the configuration file.
Expand Down

This file was deleted.

Expand Up @@ -33,6 +33,6 @@
@Inherited @Inherited
@Target({ElementType.TYPE}) @Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface InjectorKey { public @interface InjectKey {
Class<?> value(); Class<?> value();
} }

0 comments on commit 2cf0cff

Please sign in to comment.