1 /*
2 * Grapht, an open source dependency injector.
3 * Copyright 2014-2015 various contributors (see CONTRIBUTORS.txt)
4 * Copyright 2010-2014 Regents of the University of Minnesota
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20 package org.grouplens.grapht.solver;
21
22 import org.grouplens.grapht.CachePolicy;
23 import org.grouplens.grapht.reflect.QualifierMatcher;
24 import org.grouplens.grapht.reflect.Satisfaction;
25
26 /**
27 * Utility methods for {@link BindRule}.
28 */
29 public final class BindRules {
30 private BindRules() {}
31
32 /**
33 * Construct a new bind rule that binds a dependency to a satisfaction.
34 *
35 *
36 * @param depType The dependency type.
37 * @param qualifier The qualifier matcher to match the dependency type.
38 * @param satisfaction The satisfaction.
39 * @param policy The cache policy.
40 * @param terminal Whether this binding is terminal.
41 * @return A new bind rule.
42 * @deprecated Use {@link BindRuleBuilder}.
43 */
44 @Deprecated
45 public static BindRule toSatisfaction(Class<?> depType, QualifierMatcher qualifier,
46 Satisfaction satisfaction, CachePolicy policy,
47 boolean terminal) {
48 return BindRuleBuilder.create()
49 .setDependencyType(depType)
50 .setQualifierMatcher(qualifier)
51 .setSatisfaction(satisfaction)
52 .setCachePolicy(policy)
53 .setTerminal(terminal)
54 .build();
55 }
56
57 /**
58 * Construct a new bind rule that binds a dependency to a class.
59 *
60 *
61 * @param depType The dependency type.
62 * @param qualifier The qualifier matcher to match the dependency type.
63 * @param implType The implementation type to use.
64 * @param policy The cache policy.
65 * @param terminal Whether this binding is terminal.
66 * @return A new bind rule.
67 * @deprecated Use {@link BindRuleBuilder}.
68 */
69 @Deprecated
70 public static BindRule toClass(Class<?> depType, QualifierMatcher qualifier,
71 Class<?> implType, CachePolicy policy,
72 boolean terminal) {
73 return BindRuleBuilder.create()
74 .setDependencyType(depType)
75 .setQualifierMatcher(qualifier)
76 .setImplementation(implType)
77 .setCachePolicy(policy)
78 .setTerminal(terminal)
79 .build();
80 }
81 }