List of usage examples for java.lang.reflect Modifier PUBLIC
int PUBLIC
To view the source code for java.lang.reflect Modifier PUBLIC.
Click Source Link
From source file:org.gvnix.addon.geo.addon.GvNIXGeoConversionServiceMetadata.java
/** * Gets <code>afterPropertiesSet</code> method. <br> * /*from w ww.j av a2s .c om*/ * @return */ private MethodMetadata getAfterPropertiesSetMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(AFTER_PROPERTY_SET, parameterTypes); if (method != null) { // If it already exists, just return the method and omit its // generation via the ITD return method; } // Define method annotations List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); // Define method throws types List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildAfterPropertiesSetMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, AFTER_PROPERTY_SET, JavaType.VOID_PRIMITIVE, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.eclipse.wb.internal.swing.model.property.editor.accelerator.KeyStrokePropertyEditor.java
/** * Prepares {@link Map}'s for key code/name conversion. *//* w w w . j av a2 s. c o m*/ private static synchronized void prepareKeyMaps() { if (m_keyCodeToName == null) { m_keyFields = Lists.newArrayList(); m_keyCodeToName = Maps.newTreeMap(); m_keyNameToCode = Maps.newTreeMap(); // add fields try { int expected_modifiers = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL; Field[] fields = KeyEvent.class.getDeclaredFields(); for (int i = 0; i < fields.length; i++) { Field field = fields[i]; if (field.getModifiers() == expected_modifiers && field.getType() == Integer.TYPE && field.getName().startsWith("VK_")) { String name = field.getName().substring(3); Integer value = (Integer) field.get(null); m_keyFields.add(name); m_keyCodeToName.put(value, name); m_keyNameToCode.put(name, value); } } } catch (Throwable e) { DesignerPlugin.log(e); } } }
From source file:com.comphenix.protocol.wrappers.WrappedDataWatcher.java
/** * Sets the DataWatcher Item associated with a given watcher object to a * new value. If there is not already an object at this index, the * specified watcher object must have a serializer. * //from w w w. jav a 2 s .c o m * @param object Associated watcher object * @param value New value * * @throws IllegalArgumentException If the watcher object is null or must * have a serializer and does not have one. */ public void setObject(WrappedDataWatcherObject object, Object value, boolean update) { Validate.notNull(object, "Watcher object cannot be null!"); if (SETTER == null && REGISTER == null) { FuzzyReflection fuzzy = FuzzyReflection.fromClass(handleType, true); FuzzyMethodContract contract = FuzzyMethodContract.newBuilder().banModifier(Modifier.STATIC) .requireModifier(Modifier.PUBLIC).parameterExactArray(object.getHandleType(), Object.class) .build(); List<Method> methods = fuzzy.getMethodList(contract); for (Method method : methods) { if (method.getName().equals("set") || method.getName().equals("watch")) { SETTER = Accessors.getMethodAccessor(method); } else { REGISTER = Accessors.getMethodAccessor(method); } } } // Unwrap the object value = WrappedWatchableObject.getUnwrapped(value); if (hasIndex(object.getIndex())) { SETTER.invoke(handle, object.getHandle(), value); } else { object.checkSerializer(); REGISTER.invoke(handle, object.getHandle(), value); } if (update) { getWatchableObject(object.getIndex()).setDirtyState(update); } }
From source file:org.gvnix.addon.jpa.addon.audit.providers.envers.EnversRevisionLogEntityMetadataBuilder.java
private MethodMetadata getEqualsMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = helper.toAnnotedJavaType(JavaType.OBJECT); // Check if a method exist in type final MethodMetadata method = helper.methodExists(TO_STRING_METHOD, parameterTypes); if (method != null) { // If it already exists, just return the method return method; }/*w w w. j a v a 2 s .c om*/ // Define method annotations (none in this case) List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(0); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names (none in this case) List<JavaSymbolName> parameterNames = helper.toSymbolName("object"); // Create the method body InvocableMemberBodyBuilder body = new InvocableMemberBodyBuilder(); buildEqualsMethodBody(body); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(context.getMetadataId(), Modifier.PUBLIC, EQUALS_METHOD, JavaType.BOOLEAN_PRIMITIVE, parameterTypes, parameterNames, body); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata }
From source file:org.gvnix.addon.jpa.addon.batch.JpaBatchMetadata.java
/** * Gets <code>findByParameters</code> method. <br> * This method generates a item List based on a list of entity values. * // ww w.java2s. c o m * @return */ private MethodMetadata getFindByValuesMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType.convertFromJavaTypes(MAP_STRING_OBJECT); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(FIND_BY_VALUES_METHOD, parameterTypes); if (method != null) { // If it already exists, just return the method and omit its // generation via the ITD return method; } // Define method annotations List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName("propertyValues")); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildFindByValuesMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, FIND_BY_VALUES_METHOD, listOfEntitiesType, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:com.link_intersystems.lang.reflect.criteria.MemberCriteria.java
@SuppressWarnings("unchecked") protected Iterator<T> applyAccessAndNamePredicates(Iterator<T> iterator) { List<Predicate<?>> predicates = new ArrayList<Predicate<?>>(); int accessModifiers = 0; Collection<AccessType> accesses = getAccesses(); for (AccessType access : accesses) { switch (access) { case PUBLIC: accessModifiers |= Modifier.PUBLIC; break; case PRIVATE: accessModifiers |= Modifier.PRIVATE; break; case PROTECTED: accessModifiers |= Modifier.PROTECTED; break; default:/*from w w w. j a v a 2s.com*/ break; } } Predicate<Member> accessModifierPredicate = new MemberModifierPredicate(accessModifiers, Match.AT_LEAST_ONE); if (accesses.contains(AccessType.DEFAULT)) { accessModifierPredicate = OrPredicate.orPredicate(accessModifierPredicate, NotPredicate.notPredicate(new MemberModifierPredicate( Modifier.PRIVATE | Modifier.PUBLIC | Modifier.PROTECTED, Match.AT_LEAST_ONE))); } predicates.add(accessModifierPredicate); int modifiers = getModifiers(); if (modifiers != 0) { predicates.add(new MemberModifierPredicate(modifiers, Match.AT_LEAST_ALL)); } String name = getName(); if (name != null) { predicates.add(ReflectFacade.getMemberNamePredicate(name)); } Pattern pattern = getPattern(); if (pattern != null) { predicates.add(ReflectFacade.getMemberNamePatternPredicate(pattern)); } Predicate<T> allPredicate = AllPredicate.allPredicate((Collection<? extends Predicate<T>>) predicates); iterator = IteratorUtils.filteredIterator(iterator, allPredicate); return iterator; }
From source file:org.gvnix.addon.jpa.addon.audit.JpaAuditMetadata.java
/** * Create a method for revision Item class * //from w ww .jav a 2 s . co m * @param methodName * @param returnValue * @param body * @return */ private MethodMetadata createRevisionItemMethod(JavaSymbolName methodName, JavaType returnValue, InvocableMemberBodyBuilder body) { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(0); // Define method annotations (none in this case) List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(0); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(0); // Define method parameter names (none in this case) List<JavaSymbolName> parameters = new ArrayList<JavaSymbolName>(0); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, returnValue, parameterTypes, parameters, body); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata }
From source file:org.gvnix.addon.jpa.addon.audit.JpaAuditOperationsImpl.java
/** * Create the class for entity which will hold the revision information for * Hibernate Envers//from w w w. jav a2 s.co m * <p/> * This use {@link #REVISION_LOG_ENTITY_NAME} as class name and look for * <em>the first package which contains a entity</em> to place it. * */ public void installRevisonEntity(JavaType revisionEntity) { PathResolver pathResolver = projectOperations.getPathResolver(); JavaType target; if (revisionEntity == null) { target = generateRevionEntityJavaType(); } else { target = revisionEntity; } int modifier = Modifier.PUBLIC; final String declaredByMetadataId = PhysicalTypeIdentifier.createIdentifier(target, pathResolver.getFocusedPath(Path.SRC_MAIN_JAVA)); File targetFile = new File(typeLocationService.getPhysicalTypeCanonicalPath(declaredByMetadataId)); if (targetFile.exists()) { Validate.isTrue(!targetFile.exists(), "Type '%s' already exists", target); } // Prepare class builder final ClassOrInterfaceTypeDetailsBuilder cidBuilder = new ClassOrInterfaceTypeDetailsBuilder( declaredByMetadataId, modifier, target, PhysicalTypeCategory.CLASS); // Prepare annotations array List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(1); // Add @GvNIXJpaAuditListener annotation AnnotationMetadataBuilder jpaAuditRevEntAnn = new AnnotationMetadataBuilder( new JavaType(GvNIXJpaAuditRevisionEntity.class)); annotations.add(jpaAuditRevEntAnn); // Set annotations cidBuilder.setAnnotations(annotations); // Create Revision entity class typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build()); }
From source file:org.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderAuthenticationFilterMetadata.java
/** * Gets <code>getObtainToken</code> method. <br> * //w w w. j av a 2s .c o m * @return */ private MethodMetadata getObtainToken() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); parameterTypes .add(AnnotatedJavaType.convertFromJavaType(new JavaType("javax.servlet.http.HttpServletRequest"))); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(OBTAIN_TOKEN_METHOD, parameterTypes); if (method != null) { // If it already exists, just return the method and omit its // generation via the ITD return method; } // Define method annotations List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); // Define method throws types List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName("request")); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildObtainTokenMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, OBTAIN_TOKEN_METHOD, JavaType.STRING, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.gvnix.addon.geo.addon.GvNIXGeoConversionServiceMetadata.java
/** * Gets <code>getLineStringToStringConverter</code> method. <br> * /*from ww w. j a v a 2 s . com*/ * @return */ private MethodMetadata getLineStringToStringConverterMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(LINESTRING_TO_STRING_METHOD, parameterTypes); if (method != null) { // If it already exists, just return the method and omit its // generation via the ITD return method; } // Define method annotations List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); // Define method throws types List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildGetLineStringToStringConverterMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, LINESTRING_TO_STRING_METHOD, CONVERTER_LINESTRING_STRING, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }