Example usage for com.google.common.base Converter getClass

List of usage examples for com.google.common.base Converter getClass

Introduction

In this page you can find the example usage for com.google.common.base Converter getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.planet57.gshell.util.converter.Converters.java

/**
 * Sets if converters registered with the VM PropertyEditorManager.
 * If the new value is true, all currently registered converters are
 * immediately registered with the VM./*w ww  .java  2  s . c om*/
 */
public static void setRegisterWithVM(final boolean registerWithVM) {
    if (Converters.registerWithVM != registerWithVM) {
        Converters.registerWithVM = registerWithVM;

        // register all converters with the VM
        if (registerWithVM) {
            for (Entry<Class, Converter> entry : REGISTRY.entrySet()) {
                Class type = entry.getKey();
                Converter converter = entry.getValue();
                PropertyEditorManager.registerEditor(type, converter.getClass());
            }
        }
    }
}

From source file:com.planet57.gshell.util.converter.Converters.java

public static void registerConverter(final Converter converter) {
    checkNotNull(converter);/*from w  w  w  .j a  v a  2  s. c  om*/

    Class type = converter.getType();
    REGISTRY.put(type, converter);
    if (registerWithVM) {
        PropertyEditorManager.registerEditor(type, converter.getClass());
    }

    if (PRIMITIVE_TO_WRAPPER.containsKey(type)) {
        Class wrapperType = PRIMITIVE_TO_WRAPPER.get(type);
        REGISTRY.put(wrapperType, converter);
        if (registerWithVM) {
            PropertyEditorManager.registerEditor(wrapperType, converter.getClass());
        }
    } else if (WRAPPER_TO_PRIMITIVE.containsKey(type)) {
        Class primitiveType = WRAPPER_TO_PRIMITIVE.get(type);
        REGISTRY.put(primitiveType, converter);
        if (registerWithVM) {
            PropertyEditorManager.registerEditor(primitiveType, converter.getClass());
        }
    }
}

From source file:org.deephacks.tools4j.support.conversion.Conversion.java

public <T, V> void register(Converter converter) {
    if (converters.get(converter.getClass()) != null) {
        return;/*from w  w  w . j a v  a 2 s  .c  om*/
    }
    converters.put(converter.getClass(), new SourceTargetPair(converter));
    cache.clear();

}