forked from square/dagger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes issue square#261: add Provides.Type.SET_VALUES
- Loading branch information
Showing
13 changed files
with
443 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2013 Square, Inc. | ||
Copyright (C) 2013 Google, Inc. | ||
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. | ||
--> | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.example.dagger.tests</groupId> | ||
<artifactId>extension-graph-setvalues</artifactId> | ||
<version>HEAD-SNAPSHOT</version> | ||
<name>Dagger Integration Test Basic</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>@dagger.groupId@</groupId> | ||
<artifactId>dagger</artifactId> | ||
<version>@dagger.version@</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>@dagger.groupId@</groupId> | ||
<artifactId>dagger-compiler</artifactId> | ||
<version>@dagger.version@</version> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
64 changes: 64 additions & 0 deletions
64
compiler/src/it/extension-graph-setvalues/src/main/java/test/TestApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2013 Google, Inc. | ||
* Copyright (C) 2013 Square, Inc. | ||
* | ||
* 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 test; | ||
|
||
import dagger.ObjectGraph; | ||
import dagger.Module; | ||
import dagger.Provides; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
import javax.inject.Singleton; | ||
|
||
import static dagger.Provides.Type.SET; | ||
import static dagger.Provides.Type.SET_VALUES; | ||
|
||
/** | ||
* Contributions to {@code SET_VALUES} binding do not affect Set of providers. | ||
*/ | ||
class TestApp implements Runnable { | ||
@Inject Set<Provider<String>> providers; | ||
@Inject Set<String> strings; | ||
|
||
@Override public void run() { | ||
System.out.println(strings); | ||
} | ||
|
||
public static void main(String[] args) { | ||
ObjectGraph root = ObjectGraph.create(new RootModule()); | ||
ObjectGraph extension = root.plus(new ExtensionModule()); | ||
extension.get(TestApp.class).run(); | ||
} | ||
|
||
@Module(injects = TestApp.class) | ||
static class RootModule { | ||
@Provides Set<Provider<String>> providers() { | ||
return new HashSet<Provider<String>>(); | ||
} | ||
@Provides(type = SET_VALUES) Set<String> strings() { | ||
return new HashSet<String>(); | ||
} | ||
} | ||
|
||
@Module(addsTo = RootModule.class, injects = TestApp.class) | ||
static class ExtensionModule { | ||
@Provides(type = SET) String addToSet() { | ||
return "contributed"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2013 Square, Inc. | ||
Copyright (C) 2013 Google, Inc. | ||
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. | ||
--> | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.example.dagger.tests</groupId> | ||
<artifactId>multiple-modules-setvalues</artifactId> | ||
<version>HEAD-SNAPSHOT</version> | ||
<name>Dagger Integration Test Basic</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>@dagger.groupId@</groupId> | ||
<artifactId>dagger</artifactId> | ||
<version>@dagger.version@</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>@dagger.groupId@</groupId> | ||
<artifactId>dagger-compiler</artifactId> | ||
<version>@dagger.version@</version> | ||
<optional>true</optional> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
63 changes: 63 additions & 0 deletions
63
compiler/src/it/multiple-modules-setvalues/src/main/java/test/TestApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) 2013 Google, Inc. | ||
* Copyright (C) 2013 Square, Inc. | ||
* | ||
* 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 test; | ||
|
||
import dagger.ObjectGraph; | ||
import dagger.Module; | ||
import dagger.Provides; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import javax.inject.Inject; | ||
import javax.inject.Provider; | ||
import javax.inject.Singleton; | ||
|
||
import static dagger.Provides.Type.SET; | ||
import static dagger.Provides.Type.SET_VALUES; | ||
|
||
/** | ||
* Contributions to {@code SET_VALUES} binding do not affect Set of providers. | ||
*/ | ||
class TestApp implements Runnable { | ||
@Inject Set<Provider<String>> providers; | ||
@Inject Set<String> strings; | ||
|
||
@Override public void run() { | ||
System.out.println(strings); | ||
} | ||
|
||
public static void main(String[] args) { | ||
ObjectGraph root = ObjectGraph.create(new RootModule(), new ContributingModule()); | ||
root.get(TestApp.class).run(); | ||
} | ||
|
||
@Module(injects = TestApp.class) | ||
static class RootModule { | ||
@Provides Set<Provider<String>> providers() { | ||
return new HashSet<Provider<String>>(); | ||
} | ||
@Provides(type = SET_VALUES) Set<String> strings() { | ||
return new HashSet<String>(); | ||
} | ||
} | ||
|
||
@Module(injects = TestApp.class, complete = false) | ||
static class ContributingModule { | ||
@Provides(type = SET) String addToSet() { | ||
return "contributed"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.