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

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

Introduction

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

Prototype

public T put(final Class<?> key, final T value) 

Source Link

Document

Puts value into cache

Usage

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

License:Apache License

/**
 * Factory method for creating noncontextual instances
 * /* www .  j av a  2 s  . co m*/
 * @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;
}