Constructs a FragmentBundler for the provided Fragment class

@param klass the fragment class
@return this bundler instance to chain method calls
431397
public static <F extends Fragment> FragmentBundler<F> create(Class<F> klass) {
    try {
      return create(klass.newInstance());
    } catch (InstantiationException e) {
      throw new IllegalArgumentException("Class must have a no-arguments constructor.");
    } catch (IllegalAccessException e) {
      throw new IllegalArgumentException("Class must have a no-arguments constructor.");
    }
  }
368096
public static Class loadClass(String className, String bundleName, String bundleVersion, Identification id) throws ClassException, BundleException {
	if (StringUtil.isEmpty(bundleName)) return loadClass(className);
	return loadClassByBundle(className, bundleName, bundleVersion, id);
    }
636787
public InternalRunner create(Class<?> klass) throws InvocationTargetException {
        return create(klass, new Supplier<MockitoTestListener>() {
            public MockitoTestListener get() {
                return new NoOpTestListener();
            }
        });
    }
890202
public UriComponentsBuilder fragment(String fragment) {
		if (fragment != null) {
			Assert.hasLength(fragment, "'fragment' must not be empty");
			this.fragment = fragment;
		}
		else {
			this.fragment = null;
		}
		return this;
	}
705312
@VisibleForTesting
  public static <T> Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl) {
    return ServiceProviders.getCandidatesViaServiceLoader(klass, cl);
  }
1188050
private function getBundleForClass($class)
    {
        $reflectionClass = new \ReflectionClass($class);
        $bundles = $this->kernel->getBundles();

        do {
            $namespace = $reflectionClass->getNamespaceName();
            foreach ($bundles as $bundle) {
                if ('Symfony\Bundle\FrameworkBundle' === $bundle->getNamespace()) {
                    continue;
                }
                if (0 === strpos($namespace, $bundle->getNamespace())) {
                    return preg_replace('/Bundle$/', '', $bundle->getName());
                }
            }
            $reflectionClass = $reflectionClass->getParentClass();
        } while ($reflectionClass);
    }
1189569
protected void generateMethodCreateBundle(SourceWriter sourceWriter, TreeLogger logger,
      GeneratorContext context) {

    // method declaration
    sourceWriter.print("public <BUNDLE extends ");
    sourceWriter.print(NlsBundle.class.getSimpleName());
    sourceWriter.println("> BUNDLE createBundle(Class<BUNDLE> bundleInterface) {");
    sourceWriter.indent();

    // method body
    sourceWriter.println("BUNDLE bundle = getBundle(bundleInterface);");
    sourceWriter.println("if (bundle == null) {");
    sourceWriter.indent();
    // create and register
    generateBlockBundleCreation(sourceWriter, logger, context);
    sourceWriter.outdent();
    sourceWriter.println("}");

    sourceWriter.println("return bundle;");

    // end method...
    sourceWriter.outdent();
    sourceWriter.println("}");

  }
1018110
public static <C extends Configurable> C getConfiguration(Class<C> klass) {
        String defaultPropertyFile = "datumbox." + klass.getSimpleName().toLowerCase(Locale.ENGLISH) + DEFAULT_POSTFIX + ".properties";

        Properties properties = new Properties();
        
        ClassLoader cl = klass.getClassLoader();
        
        //Load default properties from jar
        try (InputStream in = cl.getResourceAsStream(defaultPropertyFile)) {
            properties.load(in);
        }
        catch(IOException ex) {
            throw new UncheckedIOException(ex);
        }
        
        //Look for user defined properties
        String propertyFile = defaultPropertyFile.replaceFirst(DEFAULT_POSTFIX, "");
        if(cl.getResource(propertyFile)!=null) {
            //Override the default if they exist
            try (InputStream in = cl.getResourceAsStream(propertyFile)) {
                properties.load(in);
            }
            catch(IOException ex) {
                throw new UncheckedIOException(ex);
            }
            logger.trace("Loading properties file {}: {}", propertyFile, properties);
        }
        else {
            logger.warn("Using default properties file {}: {}", defaultPropertyFile, properties);
        }

        return getConfiguration(klass, properties);
    }
1298054
public static boolean isFragment(Bundle bundle) {
        Dictionary<String, String> headers = bundle.getHeaders();
        return headers.get(Constants.FRAGMENT_HOST) != null;
    }
298526
public static <T extends Annotation> Method introspectAnnotationSingle(
            final Class<?> klass, final Class<T> annotationType) {
        final List<Method> methods = introspectAnnotationMultiple(klass, annotationType);
        return (methods.size() > 0) ? methods.get(0) : null;
    }
1176681
@Override
    public Bundle getBundle() {
        return parent instanceof GatewayClassLoader ? ((GatewayClassLoader) parent).getBundle() : parent instanceof LibertyLoader ? ((LibertyLoader) parent).getBundle() : null;
    }
353490
@VisibleForTesting
  public static <T> Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl) {
    Iterable<T> i = ServiceLoader.load(klass, cl);
    // Attempt to load using the context class loader and ServiceLoader.
    // This allows frameworks like http://aries.apache.org/modules/spi-fly.html to plug in.
    if (!i.iterator().hasNext()) {
      i = ServiceLoader.load(klass);
    }
    return i;
  }
1270739
public static File getClassJar(Class clazz) {
		File file = null;

		try {
			file = new File(clazz.getProtectionDomain().getCodeSource().getLocation().toURI());
		} catch (URISyntaxException e) {}

		return file;
	}
271672
public static ResourceBundle getBaseResourceBundle(Class<?> aClass, String aBundleName) {

        ResourceBundle bundle = null;
        final Class<?> clazz = aClass;
        final String bundleName = aBundleName;

        // Need a special classloader trick to load the ENGLISH messages (from the base bundle).
        // See BaseResourceBundleClassLoader for more info.
        ClassLoader cl = AccessController.doPrivileged(
                        new PrivilegedAction<ClassLoader>() {
                            public ClassLoader run() {
                                return new TraceNLSBundleClassLoader(clazz.getClassLoader(), bundleName);
                            }
                        });

        bundle = ResourceBundle.getBundle(bundleName, Locale.ENGLISH, cl);
        return bundle;

    }
1231314
@Override
	public Bundle getBundle(String bundleName) {
		final String sourceMethod = "getBundle"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(FallbackBundleResolver.class.getName(), sourceMethod, new Object[]{bundleName});
		}
		Bundle result = Platform.getBundle(bundleName);
		if (isTraceLogging) {
			log.exiting(FallbackBundleResolver.class.getName(), sourceMethod, result);
		}
		return result;
	}
1081599
public static Constructor getProtectedConstructor(Class klass, Class... paramTypes) {
        Constructor c;
        try {
            c = klass.getDeclaredConstructor(paramTypes);
            c.setAccessible(true);
            return c;
        } catch (Exception e) {
            return null;
        }
    }
73898
public static <T extends Annotation> T getAnnotation(final Class<?> componentClass,
		final Class<T> annotationClass)
	{
		T annotation = componentClass.getAnnotation(annotationClass);
		if (annotation != null)
		{
			return annotation;
		}
		for (final Class<?> ifc : componentClass.getInterfaces())
		{
			annotation = getAnnotation(ifc, annotationClass);
			if (annotation != null)
			{
				return annotation;
			}
		}
		if (!Annotation.class.isAssignableFrom(componentClass))
		{
			for (final Annotation ann : componentClass.getAnnotations())
			{
				annotation = getAnnotation(ann.annotationType(), annotationClass);
				if (annotation != null)
				{
					return annotation;
				}
			}
		}
		final Class<?> superClass = componentClass.getSuperclass();
		if (superClass == null || superClass.equals(Object.class))
		{
			return null;
		}
		return getAnnotation(superClass, annotationClass);
	}