|
Java example source code file (ModuleTest.java)
The ModuleTest.java Java example source code// Copyright 2007 Google Inc. All Rights Reserved. package com.google.inject; import junit.framework.TestCase; /** * Tests relating to modules. * * @author kevinb */ public class ModuleTest extends TestCase { static class A implements Module { public void configure(Binder binder) { binder.bind(X.class); binder.install(new B()); binder.install(new C()); } } static class B implements Module { public void configure(Binder binder) { binder.bind(Y.class); binder.install(new D()); } } static class C implements Module { public void configure(Binder binder) { binder.bind(Z.class); binder.install(new D()); } } static class D implements Module { public void configure(Binder binder) { binder.bind(W.class); } @Override public boolean equals(Object obj) { return obj.getClass() == D.class; // we're all equal in the eyes of guice } @Override public int hashCode() { return D.class.hashCode(); } } static class X {} static class Y {} static class Z {} static class W {} public void testDiamond() throws Exception { Guice.createInjector(new A()); } } Other Java examples (source code examples)Here is a short list of links related to this Java ModuleTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.