Example usage for org.apache.wicket.util.collections ClassMetaCache get

List of usage examples for org.apache.wicket.util.collections ClassMetaCache get

Introduction

In this page you can find the example usage for org.apache.wicket.util.collections ClassMetaCache get.

Prototype

public T get(final Class<?> key) 

Source Link

Document

Gets value from cache or returns null if not in cache

Usage

From source file:com.github.javawithmarcus.wicket.cdi.NonContextual.java

License:Apache License

/**
 * Factory method for creating noncontextual instances
 * //w  ww  .j  a v  a2  s . c  om
 * @param <T> Bean type.
 * @param clazz Bean class.
 * @return {@link NonContextual} instance.
 */
public static <T> NonContextual<T> of(Class<? extends T> clazz) {
    ClassMetaCache<NonContextual<?>> meta = getCache();

    @SuppressWarnings("unchecked")
    NonContextual<T> nc = (NonContextual<T>) meta.get(clazz);

    if (nc == null) {
        nc = new NonContextual<>(clazz);
        meta.put(clazz, nc);
    }
    return nc;
}