Example usage for java.lang Integer TYPE

List of usage examples for java.lang Integer TYPE

Introduction

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

Prototype

Class TYPE

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

Click Source Link

Document

The Class instance representing the primitive type int .

Usage

From source file:com.collaborne.jsonschema.generator.pojo.PojoGeneratorTest.java

@Test
public void generateInternalPrimitiveTypeReturnsPrimitiveTypeWithoutGeneration()
        throws CodeGenerationException, IOException {
    JsonNode schemaNode = jsonNodeReader.fromReader(new StringReader("{\"type\": \"string\"}"));
    SchemaTree schema = schemaLoader.load(schemaNode);
    Mapping mapping = new Mapping(URI.create("http://example.com/type.json#"), ClassName.create(Integer.TYPE));
    final AtomicBoolean writeSourceCalled = new AtomicBoolean();
    PojoGenerator generator = new PojoGenerator(null, null, null) {
        @Override//  w w w.  ja va 2 s . c o  m
        protected void writeSource(URI type, ClassName className, Buffer buffer) throws IOException {
            writeSourceCalled.set(true);
        }
    };

    ClassName className = generator.generateInternal(mapping.getTarget(), schema, mapping);
    assertEquals(mapping.getClassName(), className);
    assertFalse(writeSourceCalled.get());
}

From source file:org.jspresso.framework.util.accessor.bean.BeanListAccessor.java

/**
 * {@inheritDoc}//from   w  w  w . j av  a 2 s .  com
 */
@Override
public void addToValue(Object target, int index, Object value)
        throws IllegalAccessException, InvocationTargetException {
    if (adderAtMethod == null) {
        adderAtMethod = MethodUtils.getMatchingAccessibleMethod(getBeanClass(),
                AccessorInfo.ADDER_PREFIX + capitalizeFirst(getProperty()),
                new Class<?>[] { Integer.TYPE, getElementClass() });
    }
    try {
        adderAtMethod.invoke(getLastNestedTarget(target, getProperty()), index, value);
    } catch (InvocationTargetException ex) {
        if (ex.getCause() instanceof RuntimeException) {
            throw (RuntimeException) ex.getCause();
        }
        throw ex;
    } catch (IllegalArgumentException | NoSuchMethodException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.jabsorb.client.AccessibleObjectResolverTestCase.java

public void testResolution() {
    JSONArray args = new JSONArray();
    args.put(1);//from w ww .j a v  a2s  .c  om
    Constructor methodInt = (Constructor) resolver.resolveMethod(methodMap, "$constructor", args, serializer);
    Class[] params = methodInt.getParameterTypes();
    assertNotNull(params);
    assertEquals(1, params.length);
    assertEquals(Integer.TYPE, params[0]);
}

From source file:io.coala.guice.config.ConfigMembersInjector.java

@Override
public void injectMembers(final T instance) {
    final InjectConfig injectConfigAnnotation = field.getAnnotation(InjectConfig.class);
    final String configurationParameterName = injectConfigAnnotation.name();
    try {//from   www  .  ja va2  s. c  o  m
        final Class<?> type = this.field.getType();
        if (type == Integer.TYPE) {
            if (this.configuration.containsKey(configurationParameterName)) {
                this.field.setInt(instance, this.configuration.getInt(configurationParameterName));
            } else {
                LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                this.field.setInt(instance, injectConfigAnnotation.defaultIntValue());
            }
        } else if (type == Boolean.TYPE) {
            if (this.configuration.containsKey(configurationParameterName)) {
                this.field.setBoolean(instance, this.configuration.getBoolean(configurationParameterName));
            } else {
                LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                this.field.setBoolean(instance, injectConfigAnnotation.defaultBooleanValue());
            }

        } else if (type == Short.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                this.field.setShort(instance, this.configuration.getShort(configurationParameterName));
            } else {
                LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                this.field.setShort(instance, injectConfigAnnotation.defaultShortValue());
            }
        } else if (type == Byte.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                this.field.setByte(instance, this.configuration.getByte(configurationParameterName));
            } else {
                LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                this.field.setByte(instance, injectConfigAnnotation.defaultByteValue());
            }
        } else if (type == Long.TYPE) {
            if (this.configuration.containsKey(configurationParameterName)) {
                this.field.setLong(instance, this.configuration.getLong(configurationParameterName));
            } else {
                LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                this.field.setLong(instance, injectConfigAnnotation.defaultLongValue());
            }
        } else if (type == Float.TYPE) {
            if (this.configuration.containsKey(configurationParameterName)) {
                this.field.setFloat(instance, this.configuration.getFloat(configurationParameterName));
            } else {
                LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                this.field.setFloat(instance, injectConfigAnnotation.defaultFloatValue());
            }
        } else if (type == Double.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                this.field.setDouble(instance, this.configuration.getDouble(configurationParameterName));
            } else {
                LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                this.field.setDouble(instance, injectConfigAnnotation.defaultDoubleValue());
            }
        } else if (type == Character.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                this.field.setChar(instance,
                        this.configuration.getString(configurationParameterName).charAt(0));
            }
        } else {
            final Object property = getProperty(configurationParameterName, injectConfigAnnotation);
            this.field.set(instance, property);
        }
    } catch (final Throwable ex) {
        LOG.error("Problem injecting configuration", ex);
    }
}

From source file:net.daboross.bukkitdev.skywars.util.CrossVersion.java

/**
 * Supports Bukkit earlier than 1.6. TODO: removable?
 *//*from  w  ww  . j a  v a  2 s. com*/
public static void setHealth(Damageable d, double health) {
    Validate.notNull(d, "Damageable cannot be null");
    try {
        d.setHealth(health);
    } catch (NoSuchMethodError ignored) {
        Class<? extends Damageable> dClass = d.getClass();
        try {
            Method healthMethod = dClass.getMethod("setHealth", Integer.TYPE);
            healthMethod.invoke(d, (int) health);
        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException
                | InvocationTargetException ex) {
            SkyStatic.getLogger().log(Level.WARNING, "Couldn't find / use .setHealth method of LivingEntity!",
                    ex);
        }
    }
}

From source file:org.eclipse.gyrex.cloud.internal.zk.ZooKeeperServerApplication.java

private Object createFactory(final InetSocketAddress socketAddress, final int maxClientConnextions)
        throws Exception {
    // try ZooKeeper 3.4 way
    try {//from  w w  w  . ja v a  2 s  . c o  m
        return CloudActivator.getInstance().getBundle()
                .loadClass("org.apache.zookeeper.server.ServerCnxnFactory")
                .getMethod("createFactory", InetSocketAddress.class, Integer.TYPE)
                .invoke(null, socketAddress, maxClientConnextions);
    } catch (final Exception e) {
        LOG.debug("ZooKeeper 3.4 API not available. Falling back to ZooKeeper 3.3 API.");
    }

    // fallback to ZooKeeper 3.3 way
    // FIXME: remove this once we upgraded (bug 361524)
    try {
        return CloudActivator.getInstance().getBundle()
                .loadClass("org.apache.zookeeper.server.NIOServerCnxn$Factory")
                .getConstructor(InetSocketAddress.class, Integer.TYPE)
                .newInstance(socketAddress, maxClientConnextions);
    } catch (final Exception e) {
        throw new IllegalStateException("Unable to create ZooKeeper NIO Factory using 3.3 API.", e);
    }
}

From source file:ca.psiphon.tunneledwebview.WebViewProxySettings.java

@SuppressWarnings("rawtypes")
private static boolean setWebkitProxyICS(Context ctx, String host, int port) {
    try {/*from ww  w  .  jav a2 s .co  m*/
        Class webViewCoreClass = Class.forName("android.webkit.WebViewCore");

        Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
        if (webViewCoreClass != null && proxyPropertiesClass != null) {
            Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE, Object.class);
            Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE, String.class);

            if (m != null && c != null) {
                m.setAccessible(true);
                c.setAccessible(true);
                Object properties = c.newInstance(host, port, null);

                // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
                m.invoke(null, 193, properties);
                return true;
            }
        }
    } catch (Exception e) {
    } catch (Error e) {
    }

    return false;
}

From source file:com.sf.ddao.ops.UpdateSqlOperation.java

public boolean execute(Context context) throws Exception {
    try {//from ww  w  .jav  a  2 s  . co m
        final MethodCallCtx callCtx = CtxHelper.get(context, MethodCallCtx.class);
        PreparedStatement preparedStatement = statementFactory.createStatement(context, false);
        int res = preparedStatement.executeUpdate();
        preparedStatement.close();
        if (method.getReturnType() == Integer.TYPE || method.getReturnType() == Integer.class) {
            callCtx.setLastReturn(res);
        }
        return CONTINUE_PROCESSING;
    } catch (Exception t) {
        throw new DaoException("Failed to execute sql operation for " + method, t);
    }
}

From source file:com.dianping.cache.service.impl.ServiceMonitorServiceImpl.java

@Override
public String getClientStats(String clientIp, int skip, int size) throws Exception {
    int retry = 1;
    while (true) {
        try {//from   w ww .  j  a v  a2 s .com
            MBeanServerConnFactoryExtend serverConnFactory = getMBeanConnection(clientIp);
            MBeanServerConnection serverConn = (MBeanServerConnection) serverConnFactory.factory.getObject();
            return (String) serverConn.invoke(getStatMbeanName(), "getServiceStats",
                    new Object[] { skip, size },
                    new String[] { Integer.TYPE.getName(), Integer.TYPE.getName() });
        } catch (IOException e) {
            if (retry-- <= 0) {
                logger.warn("Get servicestats from mbean server[" + clientIp + "] failed, detail["
                        + e.getMessage() + "].");
                throw e;
            } else {
                MBeanServerConnFactoryExtend removed = mbeanServerConnections.remove(clientIp);
                try {
                    if (removed != null) {
                        removed.factory.destroy();
                    }
                } catch (Throwable e1) {
                }
            }
        }
    }
}

From source file:com.sf.ddao.factory.param.ParameterHelper.java

public static void bind(PreparedStatement preparedStatement, int idx, Object param, Class<?> clazz,
        Context context) throws SQLException {
    if (clazz == Integer.class || clazz == Integer.TYPE) {
        preparedStatement.setInt(idx, (Integer) param);
    } else if (clazz == String.class) {
        preparedStatement.setString(idx, (String) param);
    } else if (clazz == Long.class || clazz == Long.TYPE) {
        preparedStatement.setLong(idx, (Long) param);
    } else if (clazz == Boolean.class || clazz == Boolean.TYPE) {
        preparedStatement.setBoolean(idx, (Boolean) param);
    } else if (BigInteger.class.isAssignableFrom(clazz)) {
        BigInteger bi = (BigInteger) param;
        preparedStatement.setBigDecimal(idx, new BigDecimal(bi));
    } else if (Timestamp.class.isAssignableFrom(clazz)) {
        preparedStatement.setTimestamp(idx, (Timestamp) param);
    } else if (Date.class.isAssignableFrom(clazz)) {
        if (!java.sql.Date.class.isAssignableFrom(clazz)) {
            param = new java.sql.Date(((Date) param).getTime());
        }//from   w ww  . j  a  va2s. co m
        preparedStatement.setDate(idx, (java.sql.Date) param);
    } else if (BoundParameter.class.isAssignableFrom(clazz)) {
        ((BoundParameter) param).bindParam(preparedStatement, idx, context);
    } else {
        throw new SQLException("Unimplemented type mapping for " + clazz);
    }
}