Add winery source code
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / test / java / org / eclipse / winery / librarytests / InheritanceIllustration.java
1 /*******************************************************************************
2  * Copyright (c) 2012-2013 University of Stuttgart.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and the Apache License 2.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.librarytests;
13 /**
14  * This class is intended to demonstrate static resolution of overloaded methods
15  * 
16  * The output of this class is "Doing sth. with a followed by "Doing sth. with
17  * b" even if the passed "theObject" is of type B
18  */
19 public class InheritanceIllustration {
20         
21         private static class A {
22         };
23         
24         private static class B extends A {
25         };
26         
27         private static class X {
28                 
29                 public static void doSomething(A a) {
30                         System.out.println("Doing sth. with a");
31                 }
32                 
33                 public static void doSomething(B b) {
34                         System.out.println("Doing sth. with b");
35                 }
36         }
37         
38         
39         /**
40          * @param args
41          */
42         public static void main(String[] args) {
43                 A theObject = new B();
44                 X.doSomething(theObject);
45                 X.doSomething((B) theObject);
46         }
47         
48 }