Merge "HostTracker immediately ages out hosts on coordinator"
[controller.git] / opendaylight / sal / yang-prototype / sal / sal-binding-broker-impl / src / main / java / org / opendaylight / controller / sal / binding / impl / utils / GeneratorUtils.xtend
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.binding.impl.utils
9
10 import javassist.ClassPool
11 import javassist.NotFoundException
12 import javassist.LoaderClassPath
13
14 class GeneratorUtils {
15
16     static val PREFIX = "_gen.";
17
18     public static def generatedName(Class<?> cls, String suffix) {
19         '''«PREFIX»«cls.package.name».«cls.simpleName»$«suffix»'''.toString()
20     }
21
22     public static def get(ClassPool pool, Class<?> cls) {
23         try {
24             return pool.get(cls.name)
25         } catch (NotFoundException e) {
26             pool.appendClassPath(new LoaderClassPath(cls.classLoader));
27             return pool.get(cls.name)
28         }
29     }
30 }