blob: 4c585a3f4d4a5739f6ff36a941e041011b945a97 [file] [log] [blame]
crazyboblee7c9d7792007-09-09 03:41:05 +00001/*
2 * Copyright (C) 2007 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
limpbizkit916f5482008-04-16 20:51:14 +000017package com.google.inject.internal;
crazyboblee7c9d7792007-09-09 03:41:05 +000018
limpbizkit76f14572008-06-16 03:31:04 +000019import com.google.inject.TypeLiteral;
limpbizkit53664a72009-02-21 00:25:27 +000020import static com.google.inject.internal.Preconditions.checkNotNull;
crazyboblee7c9d7792007-09-09 03:41:05 +000021import com.google.inject.matcher.Matcher;
22import com.google.inject.spi.TypeConverter;
crazyboblee7c9d7792007-09-09 03:41:05 +000023
24/**
crazyboblee7c9d7792007-09-09 03:41:05 +000025 * @author crazybob@google.com (Bob Lee)
26 */
limpbizkit76f14572008-06-16 03:31:04 +000027public final class MatcherAndConverter {
crazyboblee7c9d7792007-09-09 03:41:05 +000028
limpbizkit916f5482008-04-16 20:51:14 +000029 private final Matcher<? super TypeLiteral<?>> typeMatcher;
30 private final TypeConverter typeConverter;
31 private final Object source;
crazyboblee7c9d7792007-09-09 03:41:05 +000032
limpbizkit76f14572008-06-16 03:31:04 +000033 public MatcherAndConverter(Matcher<? super TypeLiteral<?>> typeMatcher,
crazybobleeec2ef002007-09-09 03:59:08 +000034 TypeConverter typeConverter, Object source) {
kevinb9n1601ae52008-06-03 22:21:04 +000035 this.typeMatcher = checkNotNull(typeMatcher, "type matcher");
36 this.typeConverter = checkNotNull(typeConverter, "converter");
crazybobleeec2ef002007-09-09 03:59:08 +000037 this.source = source;
38 }
39
limpbizkit916f5482008-04-16 20:51:14 +000040 public TypeConverter getTypeConverter() {
41 return typeConverter;
42 }
43
44 public Matcher<? super TypeLiteral<?>> getTypeMatcher() {
45 return typeMatcher;
46 }
47
limpbizkit916f5482008-04-16 20:51:14 +000048 public Object getSource() {
49 return source;
50 }
51
52 @Override public String toString() {
53 return typeConverter + " which matches " + typeMatcher
54 + " (bound at " + source + ")";
55 }
crazyboblee7c9d7792007-09-09 03:41:05 +000056}