Example usage for java.lang Long TYPE

List of usage examples for java.lang Long TYPE

Introduction

In this page you can find the example usage for java.lang Long TYPE.

Prototype

Class TYPE

To view the source code for java.lang Long TYPE.

Click Source Link

Document

The Class instance representing the primitive type long .

Usage

From source file:org.seedstack.seed.core.internal.application.ConfigurationMembersInjector.java

@SuppressWarnings("unchecked")
private void writeArrayField(T instance) {
    ConfigurationConverter<?> converter;
    Class<?> componentType = field.getType().getComponentType();
    converter = findConverter(instance, componentType);
    String[] values = configuration.getStringArray(annotation.value());

    if ((values == null || values.length == 0) && annotation.defaultValue().length > 0) {
        values = annotation.defaultValue();
    }//from   w w  w .j a  v  a  2  s  .  c  o m

    if (values != null && values.length > 0) {
        if (componentType.isPrimitive()) {
            if (componentType == Short.TYPE) {
                writeField(instance, convertToShortValues(values, (ConfigurationConverter<Short>) converter));
            }
            if (componentType == Integer.TYPE) {
                writeField(instance,
                        convertToIntegerValues(values, (ConfigurationConverter<Integer>) converter));
            }
            if (componentType == Boolean.TYPE) {
                writeField(instance,
                        convertToBooleanValues(values, (ConfigurationConverter<Boolean>) converter));
            }
            if (componentType == Byte.TYPE) {
                writeField(instance, convertToByteValues(values, (ConfigurationConverter<Byte>) converter));
            }
            if (componentType == Long.TYPE) {
                writeField(instance, convertToLongValues(values, (ConfigurationConverter<Long>) converter));
            }
            if (componentType == Float.TYPE) {
                writeField(instance, convertToFloatValues(values, (ConfigurationConverter<Float>) converter));
            }
            if (componentType == Double.TYPE) {
                writeField(instance, convertToDoubleValues(values, (ConfigurationConverter<Double>) converter));
            }
            if (componentType == Character.TYPE) {
                writeField(instance,
                        convertToCharacterValues(values, (ConfigurationConverter<Character>) converter));
            }
        } else {
            Object[] convertedValues;
            try {
                convertedValues = (Object[]) Array.newInstance(field.getType().getComponentType(),
                        values.length);
            } catch (Exception e) {
                throw SeedException.wrap(e, ApplicationErrorCode.UNABLE_TO_INSTANTIATE_CONFIGURATION_ARRAY);
            }

            for (int i = 0; i < values.length; i++) {
                convertedValues[i] = converter.convert(values[i]);
            }
            writeField(instance, convertedValues);
        }
    } else {
        LOGGER.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, annotation.value());
    }
}

From source file:org.impalaframework.spring.service.proxy.ServiceEndpointInterceptor.java

public Object invokeDummy(MethodInvocation invocation) throws Throwable {

    log.debug("Calling method " + invocation);
    Class<?> returnType = invocation.getMethod().getReturnType();

    if (Void.TYPE.equals(returnType))
        return null;
    if (Byte.TYPE.equals(returnType))
        return (byte) 0;
    if (Short.TYPE.equals(returnType))
        return (short) 0;
    if (Integer.TYPE.equals(returnType))
        return (int) 0;
    if (Long.TYPE.equals(returnType))
        return 0L;
    if (Float.TYPE.equals(returnType))
        return 0f;
    if (Double.TYPE.equals(returnType))
        return 0d;
    if (Boolean.TYPE.equals(returnType))
        return false;

    return null;/*from  w w  w. ja va 2s .  c  o m*/
}

From source file:au.com.addstar.cellblock.configuration.AutoConfig.java

@SuppressWarnings("unchecked")
public boolean load() {
    FileConfiguration yml = new YamlConfiguration();
    try {/*w w w  .j  ava 2  s.co m*/
        if (mFile.getParentFile().exists() || mFile.getParentFile().mkdirs()) {// Make sure the file exists
            if (mFile.exists() || mFile.createNewFile()) {
                // Parse the config
                yml.load(mFile);
                for (Field field : getClass().getDeclaredFields()) {
                    ConfigField configField = field.getAnnotation(ConfigField.class);
                    if (configField == null)
                        continue;

                    String optionName = configField.name();
                    if (optionName.isEmpty())
                        optionName = field.getName();

                    field.setAccessible(true);

                    String path = (configField.category().isEmpty() ? "" : configField.category() + ".") //$NON-NLS-2$
                            + optionName;
                    if (!yml.contains(path)) {
                        if (field.get(this) == null)
                            throw new InvalidConfigurationException(
                                    path + " is required to be set! Info:\n" + configField.comment());
                    } else {
                        // Parse the value

                        if (field.getType().isArray()) {
                            // Integer
                            if (field.getType().getComponentType().equals(Integer.TYPE))
                                field.set(this, yml.getIntegerList(path).toArray(new Integer[0]));

                            // Float
                            else if (field.getType().getComponentType().equals(Float.TYPE))
                                field.set(this, yml.getFloatList(path).toArray(new Float[0]));

                            // Double
                            else if (field.getType().getComponentType().equals(Double.TYPE))
                                field.set(this, yml.getDoubleList(path).toArray(new Double[0]));

                            // Long
                            else if (field.getType().getComponentType().equals(Long.TYPE))
                                field.set(this, yml.getLongList(path).toArray(new Long[0]));

                            // Short
                            else if (field.getType().getComponentType().equals(Short.TYPE))
                                field.set(this, yml.getShortList(path).toArray(new Short[0]));

                            // Boolean
                            else if (field.getType().getComponentType().equals(Boolean.TYPE))
                                field.set(this, yml.getBooleanList(path).toArray(new Boolean[0]));

                            // String
                            else if (field.getType().getComponentType().equals(String.class)) {
                                field.set(this, yml.getStringList(path).toArray(new String[0]));
                            } else
                                throw new IllegalArgumentException("Cannot use type "
                                        + field.getType().getSimpleName() + " for AutoConfiguration"); //$NON-NLS-1$
                        } else if (List.class.isAssignableFrom(field.getType())) {
                            if (field.getGenericType() == null)
                                throw new IllegalArgumentException(
                                        "Cannot use type List without specifying generic type for AutoConfiguration");

                            Type type = ((ParameterizedType) field.getGenericType())
                                    .getActualTypeArguments()[0];

                            if (type.equals(Integer.class))
                                field.set(this, newList((Class<? extends List<Integer>>) field.getType(),
                                        yml.getIntegerList(path)));
                            else if (type.equals(Float.class))
                                field.set(this, newList((Class<? extends List<Float>>) field.getType(),
                                        yml.getFloatList(path)));
                            else if (type.equals(Double.class))
                                field.set(this, newList((Class<? extends List<Double>>) field.getType(),
                                        yml.getDoubleList(path)));
                            else if (type.equals(Long.class))
                                field.set(this, newList((Class<? extends List<Long>>) field.getType(),
                                        yml.getLongList(path)));
                            else if (type.equals(Short.class))
                                field.set(this, newList((Class<? extends List<Short>>) field.getType(),
                                        yml.getShortList(path)));
                            else if (type.equals(Boolean.class))
                                field.set(this, newList((Class<? extends List<Boolean>>) field.getType(),
                                        yml.getBooleanList(path)));
                            else if (type.equals(String.class))
                                field.set(this, newList((Class<? extends List<String>>) field.getType(),
                                        yml.getStringList(path)));
                            else
                                throw new IllegalArgumentException(
                                        "Cannot use type " + field.getType().getSimpleName() + "<" //$NON-NLS-2$
                                                + type.toString() + "> for AutoConfiguration");
                        } else if (Set.class.isAssignableFrom(field.getType())) {
                            if (field.getGenericType() == null)
                                throw new IllegalArgumentException(
                                        "Cannot use type set without specifying generic type for AytoConfiguration");

                            Type type = ((ParameterizedType) field.getGenericType())
                                    .getActualTypeArguments()[0];

                            if (type.equals(Integer.class))
                                field.set(this, newSet((Class<? extends Set<Integer>>) field.getType(),
                                        yml.getIntegerList(path)));
                            else if (type.equals(Float.class))
                                field.set(this, newSet((Class<? extends Set<Float>>) field.getType(),
                                        yml.getFloatList(path)));
                            else if (type.equals(Double.class))
                                field.set(this, newSet((Class<? extends Set<Double>>) field.getType(),
                                        yml.getDoubleList(path)));
                            else if (type.equals(Long.class))
                                field.set(this, newSet((Class<? extends Set<Long>>) field.getType(),
                                        yml.getLongList(path)));
                            else if (type.equals(Short.class))
                                field.set(this, newSet((Class<? extends Set<Short>>) field.getType(),
                                        yml.getShortList(path)));
                            else if (type.equals(Boolean.class))
                                field.set(this, newSet((Class<? extends Set<Boolean>>) field.getType(),
                                        yml.getBooleanList(path)));
                            else if (type.equals(String.class))
                                field.set(this, newSet((Class<? extends Set<String>>) field.getType(),
                                        yml.getStringList(path)));
                            else
                                throw new IllegalArgumentException(
                                        "Cannot use type " + field.getType().getSimpleName() + "<" //$NON-NLS-2$
                                                + type.toString() + "> for AutoConfiguration");
                        } else {
                            // Integer
                            if (field.getType().equals(Integer.TYPE))
                                field.setInt(this, yml.getInt(path));

                            // Float
                            else if (field.getType().equals(Float.TYPE))
                                field.setFloat(this, (float) yml.getDouble(path));

                            // Double
                            else if (field.getType().equals(Double.TYPE))
                                field.setDouble(this, yml.getDouble(path));

                            // Long
                            else if (field.getType().equals(Long.TYPE))
                                field.setLong(this, yml.getLong(path));

                            // Short
                            else if (field.getType().equals(Short.TYPE))
                                field.setShort(this, (short) yml.getInt(path));

                            // Boolean
                            else if (field.getType().equals(Boolean.TYPE))
                                field.setBoolean(this, yml.getBoolean(path));

                            // ItemStack
                            else if (field.getType().equals(ItemStack.class))
                                field.set(this, yml.getItemStack(path));

                            // String
                            else if (field.getType().equals(String.class))
                                field.set(this, yml.getString(path));
                            else
                                throw new IllegalArgumentException("Cannot use type "
                                        + field.getType().getSimpleName() + " for AutoConfiguration"); //$NON-NLS-1$
                        }
                    }
                }

                onPostLoad();
            } else {
                Bukkit.getLogger().log(Level.INFO, "Unable to create file: " + mFile.toString());
            }
        } else {
            Bukkit.getLogger().log(Level.INFO, "Unable to create file: " + mFile.getParentFile().toString());
        }
        return true;
    } catch (IOException | InvalidConfigurationException | IllegalAccessException
            | IllegalArgumentException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:io.nuun.plugin.configuration.common.ConfigurationMembersInjector.java

@Override
public void injectMembers(T instance) {
    NuunProperty injectConfigAnnotation = null;
    // The annotation is actual NuunProperty.class
    if (clonedAnno.annotationType() == NuunProperty.class) {
        injectConfigAnnotation = field.getAnnotation(NuunProperty.class);
    } else { // The annotation has the NuunProperty annotation on it we proxy it
        injectConfigAnnotation = AssertUtils.annotationProxyOf(NuunProperty.class, clonedAnno);
    }/*from w ww  . j  a  v a2s  .c  om*/

    String configurationParameterName = injectConfigAnnotation.value();

    // Pre verification //
    if (StringUtils.isEmpty(configurationParameterName)) {
        log.error("Value for annotation {} on field {} can not be null or empty.", clonedAnno.annotationType(),
                field.toGenericString());
        throw new PluginException("Value for annotation %s on field %s can not be null or empty.",
                clonedAnno.annotationType(), field.toGenericString());
    }

    if (!configuration.containsKey(configurationParameterName) && injectConfigAnnotation.mandatory()) {
        throw new PluginException("\"%s\" must be in one properties file for field %s.",
                configurationParameterName, field.toGenericString());
    }

    try {
        this.field.setAccessible(true);
        Class<?> type = field.getType();
        if (type == Integer.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setInt(instance, configuration.getInt(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setInt(instance, injectConfigAnnotation.defaultIntValue());
            }
        } else if (type == Integer.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Integer(configuration.getInt(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Integer(injectConfigAnnotation.defaultIntValue()));
            }
        } else if (type == Boolean.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setBoolean(instance, configuration.getBoolean(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setBoolean(instance, injectConfigAnnotation.defaultBooleanValue());
            }

        } else if (type == Boolean.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Boolean(configuration.getBoolean(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Boolean(injectConfigAnnotation.defaultBooleanValue()));
            }

        } else if (type == Short.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setShort(instance, configuration.getShort(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setShort(instance, injectConfigAnnotation.defaultShortValue());
            }
        } else if (type == Short.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Short(configuration.getShort(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Short(injectConfigAnnotation.defaultShortValue()));
            }
        } else if (type == Byte.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setByte(instance, configuration.getByte(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setByte(instance, injectConfigAnnotation.defaultByteValue());
            }
        } else if (type == Byte.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Byte(configuration.getByte(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Byte(injectConfigAnnotation.defaultByteValue()));
            }
        } else if (type == Long.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setLong(instance, configuration.getLong(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setLong(instance, injectConfigAnnotation.defaultLongValue());
            }
        } else if (type == Long.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Long(configuration.getLong(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Long(injectConfigAnnotation.defaultLongValue()));
            }
        } else if (type == Float.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setFloat(instance, configuration.getFloat(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setFloat(instance, injectConfigAnnotation.defaultFloatValue());
            }
        } else if (type == Float.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Float(configuration.getFloat(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Float(injectConfigAnnotation.defaultFloatValue()));
            }
        } else if (type == Double.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setDouble(instance, configuration.getDouble(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setDouble(instance, injectConfigAnnotation.defaultDoubleValue());
            }
        } else if (type == Double.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Double(configuration.getDouble(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Double(injectConfigAnnotation.defaultDoubleValue()));
            }
        } else if (type == Character.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setChar(instance, configuration.getString(configurationParameterName).charAt(0));
            }
        } else if (type == Character.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance,
                        new Character(configuration.getString(configurationParameterName).charAt(0)));
            }
        } else {
            Object property = getProperty(configurationParameterName, injectConfigAnnotation);
            field.set(instance, property);
        }
    } catch (IllegalArgumentException ex) {
        log.error("Wrong argument or argument type during configuration injection", ex);
    } catch (IllegalAccessException ex) {
        log.error("Illegal access during configuration injection", ex);
    } catch (InstantiationException ex) {
        log.error("Impossible to instantiate value converter", ex);
    } finally {
        this.field.setAccessible(false);
    }
}

From source file:net.sf.json.JSONUtils.java

/**
 * Tests if obj is a primitive number or wrapper.<br>
 *///from   ww w .j av  a  2  s  .  c  om
public static boolean isNumber(Object obj) {
    if (((obj != null) && (obj.getClass() == Byte.TYPE)) || ((obj != null) && (obj.getClass() == Short.TYPE))
            || ((obj != null) && (obj.getClass() == Integer.TYPE))
            || ((obj != null) && (obj.getClass() == Long.TYPE))
            || ((obj != null) && (obj.getClass() == Float.TYPE))
            || ((obj != null) && (obj.getClass() == Double.TYPE))) {
        return true;
    }

    if ((obj instanceof Byte) || (obj instanceof Short) || (obj instanceof Integer) || (obj instanceof Long)
            || (obj instanceof Float) || (obj instanceof Double)) {
        return true;
    }

    return false;
}

From source file:nl.strohalm.cyclos.controls.settings.EditLocalSettingsAction.java

public DataBinder<LocalSettings> getDataBinder() {
    if (dataBinder == null) {

        final BeanBinder<TransactionNumber> transactionNumberBinder = BeanBinder
                .instance(TransactionNumber.class, "transactionNumber");
        transactionNumberBinder.registerBinder("prefix", PropertyBinder.instance(String.class, "prefix"));
        transactionNumberBinder.registerBinder("padLength", PropertyBinder.instance(Integer.TYPE, "padLength"));
        transactionNumberBinder.registerBinder("suffix", PropertyBinder.instance(String.class, "suffix"));
        transactionNumberBinder.registerBinder("enabled", PropertyBinder.instance(Boolean.TYPE, "enabled"));

        final BeanBinder<LocalSettings> binder = BeanBinder.instance(LocalSettings.class);
        binder.registerBinder("applicationName", PropertyBinder.instance(String.class, "applicationName"));
        binder.registerBinder("applicationUsername",
                PropertyBinder.instance(String.class, "applicationUsername"));
        binder.registerBinder("rootUrl", PropertyBinder.instance(String.class, "rootUrl"));

        binder.registerBinder("language", PropertyBinder.instance(Language.class, "language"));
        binder.registerBinder("numberLocale",
                PropertyBinder.instance(LocalSettings.NumberLocale.class, "numberLocale"));
        binder.registerBinder("precision", PropertyBinder.instance(LocalSettings.Precision.class, "precision"));
        binder.registerBinder("highPrecision",
                PropertyBinder.instance(LocalSettings.Precision.class, "highPrecision"));
        binder.registerBinder("decimalInputMethod",
                PropertyBinder.instance(LocalSettings.DecimalInputMethod.class, "decimalInputMethod"));
        binder.registerBinder("datePattern",
                PropertyBinder.instance(LocalSettings.DatePattern.class, "datePattern"));
        binder.registerBinder("timePattern",
                PropertyBinder.instance(LocalSettings.TimePattern.class, "timePattern"));
        binder.registerBinder("timeZone",
                PropertyBinder.instance(TimeZone.class, "timeZone", TimeZoneConverter.instance()));
        binder.registerBinder("containerUrl", PropertyBinder.instance(String.class, "containerUrl"));

        binder.registerBinder("maxIteratorResults",
                PropertyBinder.instance(Integer.TYPE, "maxIteratorResults"));
        binder.registerBinder("maxPageResults", PropertyBinder.instance(Integer.TYPE, "maxPageResults"));
        binder.registerBinder("maxAjaxResults", PropertyBinder.instance(Integer.TYPE, "maxAjaxResults"));
        binder.registerBinder("maxUploadSize", PropertyBinder.instance(Integer.TYPE, "maxUploadSize"));
        binder.registerBinder("maxUploadUnits", PropertyBinder.instance(FileUnits.class, "maxUploadUnits"));
        binder.registerBinder("maxImageWidth", PropertyBinder.instance(Integer.TYPE, "maxImageWidth"));
        binder.registerBinder("maxImageHeight", PropertyBinder.instance(Integer.TYPE, "maxImageHeight"));
        binder.registerBinder("maxThumbnailWidth", PropertyBinder.instance(Integer.TYPE, "maxThumbnailWidth"));
        binder.registerBinder("maxThumbnailHeight",
                PropertyBinder.instance(Integer.TYPE, "maxThumbnailHeight"));

        binder.registerBinder("csvUseHeader", PropertyBinder.instance(Boolean.TYPE, "csvUseHeader"));
        binder.registerBinder("csvRecordSeparator",
                PropertyBinder.instance(LocalSettings.CsvRecordSeparator.class, "csvRecordSeparator"));
        binder.registerBinder("csvValueSeparator",
                PropertyBinder.instance(LocalSettings.CsvValueSeparator.class, "csvValueSeparator"));
        binder.registerBinder("csvStringQuote",
                PropertyBinder.instance(LocalSettings.CsvStringQuote.class, "csvStringQuote"));

        binder.registerBinder("cyclosId", PropertyBinder.instance(String.class, "cyclosId"));
        binder.registerBinder("smsEnabled", PropertyBinder.instance(Boolean.TYPE, "smsEnabled"));
        binder.registerBinder("sendSmsWebServiceUrl",
                PropertyBinder.instance(String.class, "sendSmsWebServiceUrl"));
        binder.registerBinder("smsCustomFieldId", PropertyBinder.instance(Long.TYPE, "smsCustomFieldId"));
        binder.registerBinder("smsChannelName", PropertyBinder.instance(String.class, "smsChannelName"));

        binder.registerBinder("emailRequired", PropertyBinder.instance(Boolean.TYPE, "emailRequired"));
        binder.registerBinder("emailUnique", PropertyBinder.instance(Boolean.TYPE, "emailUnique"));
        binder.registerBinder("transactionNumber", transactionNumberBinder);

        binder.registerBinder("brokeringExpirationPeriod",
                DataBinderHelper.timePeriodBinder("brokeringExpirationPeriod"));
        binder.registerBinder("deleteMessagesOnTrashAfter",
                DataBinderHelper.timePeriodBinder("deleteMessagesOnTrashAfter"));
        binder.registerBinder("deletePendingRegistrationsAfter",
                DataBinderHelper.timePeriodBinder("deletePendingRegistrationsAfter"));
        binder.registerBinder("memberSortOrder",
                PropertyBinder.instance(LocalSettings.SortOrder.class, "memberSortOrder"));
        binder.registerBinder("memberResultDisplay",
                PropertyBinder.instance(LocalSettings.MemberResultDisplay.class, "memberResultDisplay"));
        binder.registerBinder("adDescriptionFormat",
                PropertyBinder.instance(TextFormat.class, "adDescriptionFormat"));
        binder.registerBinder("messageFormat", PropertyBinder.instance(TextFormat.class, "messageFormat"));

        binder.registerBinder("schedulingHour", PropertyBinder.instance(Integer.TYPE, "schedulingHour"));
        binder.registerBinder("schedulingMinute", PropertyBinder.instance(Integer.TYPE, "schedulingMinute"));
        binder.registerBinder("transferListenerClass",
                PropertyBinder.instance(String.class, "transferListenerClass"));

        binder.registerBinder("maxChargebackTime", DataBinderHelper.timePeriodBinder("maxChargebackTime"));
        binder.registerBinder("chargebackDescription",
                PropertyBinder.instance(String.class, "chargebackDescription"));
        binder.registerBinder("showCountersInAdCategories",
                PropertyBinder.instance(Boolean.TYPE, "showCountersInAdCategories"));

        dataBinder = binder;// w ww .  j ava  2  s .c o m
    }
    return dataBinder;
}

From source file:net.sf.ehcache.config.BeanHandler.java

/**
 * Converts a string to an object of a particular class.
 *///w ww .java 2  s . c  om
private static Object convert(final Class toClass, final String value) throws Exception {
    if (value == null) {
        return null;
    }
    if (toClass.isInstance(value)) {
        return value;
    }
    if (toClass == Long.class || toClass == Long.TYPE) {
        return Long.decode(value);
    }
    if (toClass == Integer.class || toClass == Integer.TYPE) {
        return Integer.decode(value);
    }
    if (toClass == Boolean.class || toClass == Boolean.TYPE) {
        return Boolean.valueOf(value);
    }
    throw new Exception("Cannot convert attribute value to class " + toClass.getName());
}

From source file:com.nfwork.dbfound.json.JSONDynaBean.java

protected boolean isDynaAssignable(Class dest, Class src) {
    boolean assignable = dest.isAssignableFrom(src);
    assignable = (dest == Boolean.TYPE && src == Boolean.class) ? true : assignable;
    assignable = (dest == Byte.TYPE && src == Byte.class) ? true : assignable;
    assignable = (dest == Character.TYPE && src == Character.class) ? true : assignable;
    assignable = (dest == Short.TYPE && src == Short.class) ? true : assignable;
    assignable = (dest == Integer.TYPE && src == Integer.class) ? true : assignable;
    assignable = (dest == Long.TYPE && src == Long.class) ? true : assignable;
    assignable = (dest == Float.TYPE && src == Float.class) ? true : assignable;
    assignable = (dest == Double.TYPE && src == Double.class) ? true : assignable;

    if (src == Double.TYPE || Double.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest) || isFloat(dest)) ? true
                : assignable;//from   w  w  w . j a  va  2 s  .  com
    }
    if (src == Float.TYPE || Float.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest)) ? true : assignable;
    }
    if (src == Long.TYPE || Long.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest) || isInteger(dest)) ? true : assignable;
    }
    if (src == Integer.TYPE || Integer.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest)) ? true : assignable;
    }
    if (src == Short.TYPE || Short.class.isAssignableFrom(src)) {
        assignable = (isByte(dest)) ? true : assignable;
    }

    return assignable;
}

From source file:com._4dconcept.springframework.data.marklogic.core.MarklogicTemplate.java

@Override
public long count(Query query) {
    String ctsQuery = new CTSQuerySerializer(query).disablePagination().asCtsQuery();
    String countQuery = String.format("xdmp:estimate(%s)", ctsQuery);
    Long count = invokeAdhocQuery(countQuery, Long.TYPE, new MarklogicInvokeOperationOptions() {
        @Override//from w ww .j av a  2 s.  com
        public boolean useCacheResult() {
            return false;
        }
    });
    return count == null ? 0 : count;
}

From source file:org.briljantframework.data.resolver.Resolve.java

private static Resolver<Integer> initializeIntegerResolver() {
    Resolver<Integer> resolver = new Resolver<>(Integer.class);
    resolver.put(Number.class, Number::intValue);
    resolver.put(Double.class, Number::intValue);
    resolver.put(Double.TYPE, Number::intValue);
    resolver.put(Float.class, Number::intValue);
    resolver.put(Float.TYPE, Number::intValue);
    resolver.put(Long.class, Number::intValue);
    resolver.put(Long.TYPE, Number::intValue);
    resolver.put(Integer.class, Number::intValue);
    resolver.put(Integer.TYPE, Number::intValue);
    resolver.put(Short.class, Number::intValue);
    resolver.put(Short.TYPE, Number::intValue);
    resolver.put(Byte.class, Number::intValue);
    resolver.put(Byte.TYPE, Number::intValue);
    resolver.put(String.class, s -> {
        try {//w w w.  java  2  s  .  c  om
            return NumberUtils.createNumber(s).intValue();
        } catch (Exception e) {
            return null;
        }
    });
    return resolver;
}