998e8d6bd3eb9704a7393a4fb4c9ca37d4de807e
[utils] / system / general / src / main / java / org / wamblee / system / core / ProvidedInterfaceImplementation.java
1 /*
2  * Copyright 2008 the original author or authors.
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 package org.wamblee.system.core;
17
18 /**
19  * Represents a provided interface together with its implementation.
20  *
21  * @author Erik Brakkee
22  */
23 class ProvidedInterfaceImplementation {
24     /**
25      * DOCUMENT ME!
26      */
27     private ProvidedInterface _provided;
28
29     /**
30      * DOCUMENT ME!
31      */
32     private Object _implementation;
33
34 /**
35          * Constructs the object. 
36          * @param aProvided Provided interface. 
37          * @param aImplementation Implementation. 
38          */
39     public ProvidedInterfaceImplementation(ProvidedInterface aProvided,
40         Object aImplementation) {
41         _provided           = aProvided;
42         _implementation     = aImplementation;
43     }
44
45     /**
46      * DOCUMENT ME!
47      *
48      * @return The provided interface.
49      */
50     public ProvidedInterface getProvided() {
51         return _provided;
52     }
53
54     /**
55      * DOCUMENT ME!
56      *
57      * @param <T> Expected type of the implementation.
58      * @param aType Type of the implementation.
59      *
60      * @return Implementation.
61      */
62     public <T> T getImplementation(Class<T> aType) {
63         return (T) _implementation;
64     }
65 }