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.web.screen.roo.addon.EntityBatchMetadata.java
/** * Generate a setter for <code>field</code> * //from w ww .j av a 2 s . c o m * @param field field metadata * @return */ private MethodMetadataBuilder getListInner_setter(FieldMetadata field) { // Gets filed name String fieldName = field.getFieldName().getSymbolName(); // prepares method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.appendFormalLine(MessageFormat.format("this.{0} = {0};", new Object[] { fieldName })); // Create method builder MethodMetadataBuilder builder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, new JavaSymbolName("set".concat(StringUtils.capitalize(fieldName))), JavaType.VOID_PRIMITIVE, bodyBuilder); // Adds setter parameter List<AnnotationMetadata> annotations = new ArrayList<AnnotationMetadata>(); builder.addParameterType(new AnnotatedJavaType(field.getFieldType(), annotations)); builder.addParameterName(field.getFieldName()); return builder; }
From source file:org.exem.flamingo.shared.util.el.ELServiceImpl.java
public static Object findConstant(String className, String constantName) throws ServiceException { try {/*from w ww . j a v a 2 s . c om*/ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className); Field field = clazz.getField(constantName); if ((field.getModifiers() & (Modifier.PUBLIC | Modifier.STATIC)) != (Modifier.PUBLIC | Modifier.STATIC)) { // throw new ServiceException(ErrorCode.E0114, className, constantName); } return field.get(null); } catch (Exception ex) { throw new ServiceException(ex); } }
From source file:org.mule.module.extension.internal.util.IntrospectionUtils.java
public static Method getOperationMethod(Class<?> declaringClass, Operation operation) { Class<?>[] parameterTypes; if (operation.getParameters().isEmpty()) { parameterTypes = org.apache.commons.lang.ArrayUtils.EMPTY_CLASS_ARRAY; } else {//from w w w . j a v a 2 s .com parameterTypes = new Class<?>[operation.getParameters().size()]; int i = 0; for (Parameter parameter : operation.getParameters()) { parameterTypes[i++] = parameter.getType().getRawType(); } } Collection<Method> methods = getAllMethods(declaringClass, withAnnotation(org.mule.extension.annotations.Operation.class), withModifier(Modifier.PUBLIC), withName(operation.getName()), withParameters(parameterTypes)); checkArgument(!methods.isEmpty(), String.format("Could not find method %s in class %s", operation.getName(), declaringClass.getName())); checkArgument(methods.size() == 1, String.format("More than one matching method was found in class %s for operation %s", declaringClass.getName(), operation.getName())); return methods.iterator().next(); }
From source file:org.gvnix.addon.jpa.addon.geo.providers.hibernatespatial.GvNIXEntityMapLayerMetadata.java
/** * Create a method to filter by two or more geometry fields from an entity * // w ww .ja v a2s .c o m * @param entity * @param finders * @param plural * @param geoFieldNames * @return */ private MethodMetadata getfindAllTheEntityByFilters(JavaType entity, String finders[], String plural, Map<JavaSymbolName, AnnotationAttributeValue<Integer>> geoFields) { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); // Adding parameter types parameterTypes.add(AnnotatedJavaType .convertFromJavaType(new JavaType("org.gvnix.jpa.geo.hibernatespatial.util.GeometryFilter"))); parameterTypes.add(AnnotatedJavaType.convertFromJavaType( new JavaType("java.lang.Class", 0, DataType.TYPE, null, Arrays.asList(new JavaType("T"))))); parameterTypes.add(AnnotatedJavaType.convertFromJavaType(new JavaType(MAP.getFullyQualifiedTypeName(), 0, DataType.TYPE, null, Arrays.asList(JavaType.STRING, JavaType.OBJECT)))); // Getting method name StringBuilder methodNameBuilder = new StringBuilder(String.format("findAll%sBy", plural)); for (String field : finders) { methodNameBuilder.append(StringUtils.capitalize(field).concat("Or")); } JavaSymbolName methodName = new JavaSymbolName( methodNameBuilder.substring(0, methodNameBuilder.length() - 2)); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(methodName, 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("geomFilter")); parameterNames.add(new JavaSymbolName("klass")); parameterNames.add(new JavaSymbolName("hints")); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildfindAllTheEntityByGeoFiltersMethodBody(entity, plural, finders, bodyBuilder, geoFields); // Return type JavaType responseEntityJavaType = new JavaType("java.util.List", 0, DataType.TYPE, null, Arrays.asList(new JavaType("T"))); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC + Modifier.STATIC, methodName, responseEntityJavaType, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); methodBuilder.setGenericDefinition("T"); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:org.gvnix.flex.FlexScaffoldMetadata.java
private MethodMetadata getListMethod() { JavaSymbolName methodName = new JavaSymbolName("list"); MethodMetadata method = methodExists(methodName); if (method != null) { return method; }//from w ww . j a v a 2 s . c o m List<JavaType> typeParams = new ArrayList<JavaType>(); typeParams.add(this.entity); JavaType returnType = new JavaType("java.util.List", 0, DataType.TYPE, null, typeParams); InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.appendFormalLine("return " + this.entity.getNameIncludingTypeParameters(false, this.builder.getImportRegistrationResolver()) + "." + new JpaCrudAnnotationValues(this.entityMetadata).getFindAllMethod() .concat(this.entityMetadata.getPlural()) + "();"); return new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, returnType, null, null, bodyBuilder) .build(); }
From source file:org.openflamingo.uploader.el.ELService.java
public static Object findConstant(String className, String constantName) throws SystemException { try {//from ww w. j a v a 2 s .co m Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className); Field field = clazz.getField(constantName); if ((field.getModifiers() & (Modifier.PUBLIC | Modifier.STATIC)) != (Modifier.PUBLIC | Modifier.STATIC)) { // throw new SystemException(ErrorCode.E0114, className, constantName); } return field.get(null); } catch (IllegalAccessException ex) { throw new SystemException(ex); } catch (NoSuchFieldException ex) { throw new SystemException(ex); } catch (ClassNotFoundException ex) { throw new SystemException(ex); } }
From source file:org.codehaus.groovy.grails.compiler.injection.DefaultGrailsDomainClassInjector.java
private void injectIdProperty(ClassNode classNode) { final boolean hasId = /*GrailsASTUtils.*/hasProperty(classNode, /*GrailsDomainClassProperty.*/IDENTITY); if (!hasId) { //if(LOG.isDebugEnabled()) { // LOG.debug("[GrailsDomainInjector] Adding property [" + GrailsDomainClassProperty.IDENTITY + "] to class [" + classNode.getName() + "]"); //}/* www . j a v a 2 s .c o m*/ classNode.addProperty( /*GrailsDomainClassProperty.*/IDENTITY, Modifier.PUBLIC, new ClassNode(Long.class), null, null, null); } }
From source file:hu.bme.mit.sette.common.model.snippet.SnippetContainer.java
/** * Validates the fields of the class.//w w w . j ava 2 s . c om * * @param validator * a validator */ private void validateFields(final AbstractValidator<?> validator) { // check: only constant ("public static final") or synthetic fields for (Field field : javaClass.getDeclaredFields()) { if (field.isSynthetic()) { // skip for synthetic fields (e.g. switch for enum generates // synthetic methods and fields) continue; } FieldValidator v = new FieldValidator(field); v.withModifiers(Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL); v.withoutModifiers(Modifier.SYNCHRONIZED | Modifier.TRANSIENT | Modifier.VOLATILE); validator.addChildIfInvalid(v); } }
From source file:hu.bme.mit.sette.common.model.snippet.SnippetInputFactoryContainer.java
/** * Validates methods of the class./*from w ww. ja va2 s . c om*/ * * @param validator * a validator * @return a map containing the input factory methods by their name */ private Map<String, Method> validateMethods(final AbstractValidator<?> validator) { // check: only "public static" or synthetic methods Map<String, Method> factoryMethods = new HashMap<String, Method>(); for (Method method : javaClass.getDeclaredMethods()) { if (method.isSynthetic()) { // skip synthetic methods continue; } MethodValidator v = new MethodValidator(method); if (factoryMethods.get(method.getName()) != null) { v.addException("The method must have a unique name"); } v.withModifiers(Modifier.PUBLIC | Modifier.STATIC); v.withoutModifiers(Modifier.ABSTRACT | Modifier.FINAL | Modifier.NATIVE | Modifier.SYNCHRONIZED); factoryMethods.put(method.getName(), method); validator.addChildIfInvalid(v); } return factoryMethods; }