List of usage examples for java.lang Long TYPE
Class TYPE
To view the source code for java.lang Long TYPE.
Click Source Link
From source file:com.nfwork.dbfound.json.JSONDynaBean.java
private boolean isLong(Class clazz) { return Long.class.isAssignableFrom(clazz) || clazz == Long.TYPE; }
From source file:org.wrml.runtime.syntax.DefaultSyntaxLoader.java
private final void loadSystemSyntaxes() { for (final SystemSyntax systemSyntax : SystemSyntax.values()) { final SyntaxHandler<?> syntaxHandler = systemSyntax.getSyntaxHandler(); switch (systemSyntax) { case Boolean: _SyntaxHandlers.put(Boolean.TYPE, syntaxHandler); break; case Double: _SyntaxHandlers.put(Double.TYPE, syntaxHandler); break; case Integer: _SyntaxHandlers.put(Integer.TYPE, syntaxHandler); break; case Long: _SyntaxHandlers.put(Long.TYPE, syntaxHandler); break; default:/*w w w .j a v a2 s .c o m*/ break; } final URI syntaxUri = systemSyntax.getSyntaxUri(); loadSyntaxInternal(syntaxUri, syntaxHandler); } final Context context = getContext(); // Loop again to build the system Syntax models now that the for (final SystemSyntax systemSyntax : SystemSyntax.values()) { final Syntax syntax = context.newModel(Syntax.class); final URI syntaxUri = systemSyntax.getSyntaxUri(); syntax.setUniqueName(systemSyntax.getUniqueName()); syntax.setUri(syntaxUri); _SystemSyntaxes.put(syntaxUri, syntax); } }
From source file:org.apache.mina.statemachine.transition.MethodTransition.java
@SuppressWarnings("unchecked") private boolean match(Class<?> paramType, Object arg, Class argType) { if (paramType.isPrimitive()) { if (paramType.equals(Boolean.TYPE)) { return arg instanceof Boolean; }//from ww w. j a v a 2 s .c o m if (paramType.equals(Integer.TYPE)) { return arg instanceof Integer; } if (paramType.equals(Long.TYPE)) { return arg instanceof Long; } if (paramType.equals(Short.TYPE)) { return arg instanceof Short; } if (paramType.equals(Byte.TYPE)) { return arg instanceof Byte; } if (paramType.equals(Double.TYPE)) { return arg instanceof Double; } if (paramType.equals(Float.TYPE)) { return arg instanceof Float; } if (paramType.equals(Character.TYPE)) { return arg instanceof Character; } } return argType.isAssignableFrom(paramType) && paramType.isAssignableFrom(arg.getClass()); }
From source file:com.evolveum.polygon.connector.googleapps.GroupHandler.java
public static ObjectClassInfo getGroupClassInfo() { // @formatter:off /* GROUP from https://devsite.googleplex.com/admin-sdk/directory/v1/reference/groups#resource {/*from w w w . j a va2 s.co m*/ "kind": "admin#directory#group", "id": string, "etag": etag, "email": string, "name": string, "directMembersCount": long, "description": string, "adminCreated": boolean, "aliases": [ string ], "nonEditableAliases": [ string ] } */ // @formatter:on ObjectClassInfoBuilder builder = new ObjectClassInfoBuilder(); builder.setType(ObjectClass.GROUP_NAME); // email builder.addAttributeInfo(Name.INFO); builder.addAttributeInfo(AttributeInfoBuilder.build(NAME_ATTR)); builder.addAttributeInfo(PredefinedAttributeInfos.DESCRIPTION); // Read-only builder.addAttributeInfo(AttributeInfoBuilder.define(ADMIN_CREATED_ATTR, Boolean.TYPE).setUpdateable(false) .setCreateable(false).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(ALIASES_ATTR).setUpdateable(false).setCreateable(false) .setMultiValued(true).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(NON_EDITABLE_ALIASES_ATTR).setUpdateable(false) .setCreateable(false).setMultiValued(true).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(DIRECT_MEMBERS_COUNT_ATTR, Long.TYPE) .setUpdateable(false).setCreateable(false).build()); // Virtual Attribute builder.addAttributeInfo( AttributeInfoBuilder.define(MEMBERS_ATTR).setMultiValued(true).setReturnedByDefault(false).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_allowExternalMembers).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_allowGoogleCommunication).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_allowWebPosting).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_archiveOnly).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_customFooterText).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_customReplyTo).build()); builder.addAttributeInfo(AttributeInfoBuilder .define(GoogleAppsConnector.SETTING_defaultMessageDenyNotificationText).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_description).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_email).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_includeCustomFooter).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_includeInGlobalAddressList).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_isArchived).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_maxMessageBytes, Integer.TYPE).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_membersCanPostAsTheGroup).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_messageDisplayFont).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_messageModerationLevel).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_name).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_replyTo).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_sendMessageDenyNotification).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_showInGroupDirectory).build());//rizeno builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_spamModerationLevel).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanAdd).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanContactOwner).build());//rizeno builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanInvite).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanJoin).build());//rizeno builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanLeaveGroup).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanPostMessage).build());//rizeno builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanViewGroup).build());//rizeno builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanViewMembership).build());//rizeno return builder.build(); }
From source file:org.wisdom.template.thymeleaf.OgnlOpsByReflectionTest.java
@Test public void testConvertValue() throws Exception { Class[] classes = new Class[] { Object.class, Class.class }; // Null value assertThat(invoke("convertValue", classes, null, Long.TYPE)).isEqualTo(0l); assertThat(invoke("convertValue", classes, null, String.class)).isNull(); // Primitive/* w ww . j a va 2s . c o m*/ assertThat(invoke("convertValue", classes, "42", Integer.class)).isEqualTo(42); assertThat(invoke("convertValue", classes, "42", Integer.TYPE)).isEqualTo(42); assertThat(invoke("convertValue", classes, "42", Byte.class)).isEqualTo(Byte.valueOf("42")); assertThat(invoke("convertValue", classes, "42", Byte.TYPE)).isEqualTo(Byte.valueOf("42")); assertThat(invoke("convertValue", classes, "42", Short.class)).isEqualTo(Short.valueOf("42")); assertThat(invoke("convertValue", classes, "42", Short.TYPE)).isEqualTo(Short.valueOf("42")); assertThat(invoke("convertValue", classes, String.valueOf((int) 'c'), Character.class)).isEqualTo('c'); assertThat(invoke("convertValue", classes, String.valueOf((int) 'c'), Character.TYPE)).isEqualTo('c'); assertThat(invoke("convertValue", classes, "42", Long.class)).isEqualTo(42l); assertThat(invoke("convertValue", classes, "42", Long.TYPE)).isEqualTo(42l); assertThat(invoke("convertValue", classes, "true", Boolean.class)).isEqualTo(true); assertThat(invoke("convertValue", classes, "true", Boolean.TYPE)).isEqualTo(true); assertThat(invoke("convertValue", classes, "42", Double.class)).isEqualTo(42.0); assertThat(invoke("convertValue", classes, "42", Double.TYPE)).isEqualTo(42.0); assertThat(invoke("convertValue", classes, "42", Float.class)).isEqualTo(42.0f); assertThat(invoke("convertValue", classes, "42", Float.TYPE)).isEqualTo(42.0f); // BigInteger, BigDecimal and String assertThat(invoke("convertValue", classes, "42", BigDecimal.class)).isEqualTo(new BigDecimal("42")); assertThat(invoke("convertValue", classes, "42", BigInteger.class)).isEqualTo(new BigInteger("42")); assertThat(invoke("convertValue", classes, "42", String.class)).isEqualTo("42"); //Array assertThat(invoke("convertValue", classes, new Object[] { 1, 2, 3 }, (new int[0]).getClass())).isNotNull(); }
From source file:com.ryan.ryanreader.jsonwrap.JsonBufferedObject.java
public void populateObject(final Object o) throws InterruptedException, IOException, IllegalArgumentException, InstantiationException, NoSuchMethodException, InvocationTargetException { if (join() != Status.LOADED) { throwFailReasonException();/*from w ww. j a v a 2 s. com*/ } final Field[] objectFields = o.getClass().getFields(); try { for (final Field objectField : objectFields) { if ((objectField.getModifiers() & Modifier.TRANSIENT) != 0) { continue; } final JsonValue val; if (properties.containsKey(objectField.getName())) { val = properties.get(objectField.getName()); } else if (objectField.getName().startsWith("_json_")) { val = properties.get(objectField.getName().substring("_json_".length())); } else { val = null; } if (val == null) { continue; } objectField.setAccessible(true); final Class<?> fieldType = objectField.getType(); if (fieldType == Long.class || fieldType == Long.TYPE) { objectField.set(o, val.asLong()); } else if (fieldType == Double.class || fieldType == Double.TYPE) { objectField.set(o, val.asDouble()); } else if (fieldType == Integer.class || fieldType == Integer.TYPE) { objectField.set(o, val.isNull() ? null : val.asLong().intValue()); } else if (fieldType == Float.class || fieldType == Float.TYPE) { objectField.set(o, val.isNull() ? null : val.asDouble().floatValue()); } else if (fieldType == Boolean.class || fieldType == Boolean.TYPE) { objectField.set(o, val.asBoolean()); } else if (fieldType == String.class) { objectField.set(o, val.asString()); } else if (fieldType == JsonBufferedArray.class) { objectField.set(o, val.asArray()); } else if (fieldType == JsonBufferedObject.class) { objectField.set(o, val.asObject()); } else if (fieldType == JsonValue.class) { objectField.set(o, val); } else if (fieldType == Object.class) { final Object result; switch (val.getType()) { case BOOLEAN: result = val.asBoolean(); break; case INTEGER: result = val.asLong(); break; case STRING: result = val.asString(); break; case FLOAT: result = val.asDouble(); break; default: result = val; } objectField.set(o, result); } else { objectField.set(o, val.asObject(fieldType)); } } } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
From source file:org.androidtransfuse.analysis.FragmentAnalysis.java
private void setupFragmentProfile(ComponentDescriptor fragmentDescriptor, ASTType astType, ASTType fragmentType, AnalysisContext context, Integer layout) { ASTMethod onCreateViewMethod = getASTMethod("onCreateView", LayoutInflater.class, ViewGroup.class, Bundle.class); fragmentDescriptor.setInitMethodBuilder(astClassFactory.getType(OnCreate.class), componentBuilderFactory.buildFragmentMethodBuilder(layout, onCreateViewMethod)); fragmentDescriptor.setInjectionNodeFactory(componentBuilderFactory .buildInjectionNodeFactory(ImmutableSet.<ASTAnnotation>of(), astType, context)); //onActivityCreated fragmentDescriptor/*from ww w . j ava 2 s. c o m*/ .addGenerators(buildEventMethod(OnActivityCreated.class, "onActivityCreated", Bundle.class)); //onStart fragmentDescriptor.addGenerators(buildEventMethod(OnStart.class, "onStart")); //onResume fragmentDescriptor.addGenerators(buildEventMethod(OnResume.class, "onResume")); //onPause fragmentDescriptor.addGenerators(buildEventMethod(OnPause.class, "onPause")); //onStop fragmentDescriptor.addGenerators(buildEventMethod(OnStop.class, "onStop")); //onDestroyView fragmentDescriptor.addGenerators(buildEventMethod(OnDestroyView.class, "onDestroyView")); //onDestroy fragmentDescriptor.addGenerators(buildEventMethod(OnDestroy.class, "onDestroy")); //onDetach fragmentDescriptor.addGenerators(buildEventMethod(OnDetach.class, "onDetach")); //onLowMemory fragmentDescriptor.addGenerators(buildEventMethod(OnLowMemory.class, "onLowMemory")); //onConfigurationChanged fragmentDescriptor.addGenerators( buildEventMethod(OnConfigurationChanged.class, "onConfigurationChanged", Configuration.class)); if (fragmentType.extendsFrom(astClassFactory.getType(ListFragment.class))) { ASTMethod onListItemClickMethod = getASTMethod(ListActivity.class, "onListItemClick", ListView.class, View.class, Integer.TYPE, Long.TYPE); fragmentDescriptor.addGenerators(componentBuilderFactory.buildMethodCallbackGenerator( astClassFactory.getType(OnListItemClick.class), componentBuilderFactory.buildMirroredMethodGenerator(onListItemClickMethod, false))); } fragmentDescriptor.addGenerators(listenerRegistrationGenerator); fragmentDescriptor.addRegistration(observesExpressionDecorator); }
From source file:org.quantumbadger.redreader.jsonwrap.JsonBufferedObject.java
public void populateObject(final Object o) throws InterruptedException, IOException, IllegalArgumentException, InstantiationException, NoSuchMethodException, InvocationTargetException { if (join() != STATUS_LOADED) { throwFailReasonException();//from w w w. ja va 2 s. c om } final Field[] objectFields = o.getClass().getFields(); try { for (final Field objectField : objectFields) { if ((objectField.getModifiers() & Modifier.TRANSIENT) != 0) { continue; } final JsonValue val; if (properties.containsKey(objectField.getName())) { val = properties.get(objectField.getName()); } else if (objectField.getName().startsWith("_json_")) { val = properties.get(objectField.getName().substring("_json_".length())); } else { val = null; } if (val == null) { continue; } objectField.setAccessible(true); final Class<?> fieldType = objectField.getType(); if (fieldType == Long.class || fieldType == Long.TYPE) { objectField.set(o, val.asLong()); } else if (fieldType == Double.class || fieldType == Double.TYPE) { objectField.set(o, val.asDouble()); } else if (fieldType == Integer.class || fieldType == Integer.TYPE) { objectField.set(o, val.isNull() ? null : val.asLong().intValue()); } else if (fieldType == Float.class || fieldType == Float.TYPE) { objectField.set(o, val.isNull() ? null : val.asDouble().floatValue()); } else if (fieldType == Boolean.class || fieldType == Boolean.TYPE) { objectField.set(o, val.asBoolean()); } else if (fieldType == String.class) { objectField.set(o, val.asString()); } else if (fieldType == JsonBufferedArray.class) { objectField.set(o, val.asArray()); } else if (fieldType == JsonBufferedObject.class) { objectField.set(o, val.asObject()); } else if (fieldType == JsonValue.class) { objectField.set(o, val); } else if (fieldType == Object.class) { final Object result; switch (val.getType()) { case JsonValue.TYPE_BOOLEAN: result = val.asBoolean(); break; case JsonValue.TYPE_INTEGER: result = val.asLong(); break; case JsonValue.TYPE_STRING: result = val.asString(); break; case JsonValue.TYPE_FLOAT: result = val.asDouble(); break; default: result = val; } objectField.set(o, result); } else { objectField.set(o, val.asObject(fieldType)); } } } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
From source file:org.kordamp.ezmorph.bean.MorphDynaBean.java
protected boolean isDynaAssignable(Class dest, Class src) { boolean assignable = dest.isAssignableFrom(src); if (assignable) { return true; }//from w w w . j a va2 s .c om assignable = (dest == Boolean.TYPE && src == Boolean.class) || assignable; assignable = (dest == Byte.TYPE && src == Byte.class) || assignable; assignable = (dest == Character.TYPE && src == Character.class) || assignable; assignable = (dest == Short.TYPE && src == Short.class) || assignable; assignable = (dest == Integer.TYPE && src == Integer.class) || assignable; assignable = (dest == Long.TYPE && src == Long.class) || assignable; assignable = (dest == Float.TYPE && src == Float.class) || assignable; assignable = (dest == Double.TYPE && src == Double.class) || assignable; if (src == Double.TYPE || Double.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest) || isFloat(dest)) || assignable; } if (src == Float.TYPE || Float.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest)) || assignable; } if (src == Long.TYPE || Long.class.isAssignableFrom(src)) { assignable = (isByte(dest) || isShort(dest) || isInteger(dest)) || assignable; } if (src == Integer.TYPE || Integer.class.isAssignableFrom(src)) assignable = (isByte(dest) || isShort(dest)) || assignable; if (src == Short.TYPE || Short.class.isAssignableFrom(src)) { assignable = (isByte(dest)) || assignable; } return assignable; }
From source file:org.apache.directory.server.core.integ.CreateLdapConnectionPoolRule.java
private LdapConnectionPool createLdapConnectionPool(LdapServer ldapServer, Class<? extends PooledObjectFactory<LdapConnection>> factoryClass, Class<? extends LdapConnectionFactory> connectionFactoryClass, Class<? extends LdapConnectionValidator> validatorClass) { LdapConnectionConfig config = new LdapConnectionConfig(); config.setLdapHost(Network.LOOPBACK_HOSTNAME); config.setLdapPort(ldapServer.getPort()); config.setName("uid=admin,ou=system"); config.setCredentials("secret"); if ((createLdapConnectionPool.additionalBinaryAttributes() != null) && (createLdapConnectionPool.additionalBinaryAttributes().length > 0)) { DefaultConfigurableBinaryAttributeDetector binaryAttributeDetector = new DefaultConfigurableBinaryAttributeDetector(); binaryAttributeDetector.addBinaryAttribute(createLdapConnectionPool.additionalBinaryAttributes()); config.setBinaryAttributeDetector(binaryAttributeDetector); }//ww w. j av a 2 s.c o m GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setLifo(createLdapConnectionPool.lifo()); poolConfig.setMaxTotal(createLdapConnectionPool.maxActive()); poolConfig.setMaxIdle(createLdapConnectionPool.maxIdle()); poolConfig.setMaxWaitMillis(createLdapConnectionPool.maxWait()); poolConfig.setMinEvictableIdleTimeMillis(createLdapConnectionPool.minEvictableIdleTimeMillis()); poolConfig.setMinIdle(createLdapConnectionPool.minIdle()); poolConfig.setNumTestsPerEvictionRun(createLdapConnectionPool.numTestsPerEvictionRun()); poolConfig.setSoftMinEvictableIdleTimeMillis(createLdapConnectionPool.softMinEvictableIdleTimeMillis()); poolConfig.setTestOnBorrow(createLdapConnectionPool.testOnBorrow()); poolConfig.setTestOnReturn(createLdapConnectionPool.testOnReturn()); poolConfig.setTestWhileIdle(createLdapConnectionPool.testWhileIdle()); poolConfig.setTimeBetweenEvictionRunsMillis(createLdapConnectionPool.timeBetweenEvictionRunsMillis()); poolConfig.setBlockWhenExhausted(createLdapConnectionPool.whenExhaustedAction() == 1); try { Constructor<? extends LdapConnectionFactory> constructor = connectionFactoryClass .getConstructor(LdapConnectionConfig.class); ldapConnectionFactory = constructor.newInstance(config); } catch (Exception e) { throw new IllegalArgumentException( "invalid connectionFactoryClass " + connectionFactoryClass.getName() + ": " + e.getMessage(), e); } try { Method timeoutSetter = connectionFactoryClass.getMethod("setTimeOut", Long.TYPE); if (timeoutSetter != null) { timeoutSetter.invoke(ldapConnectionFactory, createLdapConnectionPool.timeout()); } } catch (Exception e) { throw new IllegalArgumentException("invalid connectionFactoryClass " + connectionFactoryClass.getName() + ", missing setTimeOut(long): " + e.getMessage(), e); } try { Constructor<? extends PooledObjectFactory<LdapConnection>> constructor = factoryClass .getConstructor(LdapConnectionFactory.class); poolableLdapConnectionFactory = constructor.newInstance(ldapConnectionFactory); } catch (Exception e) { throw new IllegalArgumentException( "invalid factoryClass " + factoryClass.getName() + ": " + e.getMessage(), e); } try { Method setValidator = factoryClass.getMethod("setValidator", LdapConnectionValidator.class); if (setValidator != null) { setValidator.invoke(poolableLdapConnectionFactory, validatorClass.newInstance()); } } catch (Exception e) { throw new IllegalArgumentException("invalid connectionFactoryClass " + connectionFactoryClass.getName() + ", missing setTimeOut(long): " + e.getMessage(), e); } return new LdapConnectionPool(poolableLdapConnectionFactory, poolConfig); }