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.jpa.annotations.geo.providers.hibernatespatial.GvNIXEntityMapLayerMetadata.java
/** * Gets <code>findAllEntitiesByBoundingBox</code> method. <br> * /*from w w w. ja va 2 s . c o m*/ * @return */ private MethodMetadata getFindAllEntitiesByBoundingBoxMethod(JavaType entity, String plural, List<JavaSymbolName> geoFieldNames) { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); // Adding String param parameterTypes.add(AnnotatedJavaType.convertFromJavaType(JavaType.STRING)); // Getting method name JavaSymbolName methodName = new JavaSymbolName(String.format("findAll%sByBoundingBox", plural)); // 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>(); // bbox parameter parameterNames.add(new JavaSymbolName("bbox")); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildfindAllEntitiesByBoundingBoxMethodBody(entity, plural, bodyBuilder, geoFieldNames); // Return type JavaType responseEntityJavaType = new JavaType("java.util.List", 0, DataType.TYPE, null, Arrays.asList(entity)); // 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); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:pl.burningice.plugins.image.ast.AbstractImageContainerTransformation.java
protected FieldNode getHasManyField(ClassNode node) { FieldNode hasManyField = node.getDeclaredField("hasMany"); if (hasManyField != null) { return hasManyField; }// w w w . j av a 2 s. com hasManyField = new FieldNode("hasMany", Modifier.PRIVATE | Modifier.STATIC, new ClassNode(Map.class), new ClassNode(node.getClass()), new MapExpression()); node.addField(hasManyField); addGetter(hasManyField, node, Modifier.PUBLIC | Modifier.STATIC); addSetter(hasManyField, node, Modifier.PUBLIC | Modifier.STATIC); return hasManyField; }
From source file:org.gvnix.web.screen.roo.addon.EntityBatchMetadata.java
/** * Gets Inner class to manage elements list for batch operations * /*ww w . ja va2s . co m*/ * @return */ public ClassOrInterfaceTypeDetails getListInnerClass() { // Generate inner class name JavaType listInnerClassJavaType = new JavaType(destination.getSimpleTypeName().concat("List"), 0, DataType.TYPE, null, null); // Create class builder ClassOrInterfaceTypeDetailsBuilder classBuilder = new ClassOrInterfaceTypeDetailsBuilder(getId(), Modifier.STATIC | Modifier.PUBLIC, listInnerClassJavaType, PhysicalTypeCategory.CLASS); // Add fields FieldMetadata listField = getListInner_field("list", destination).build(); FieldMetadata selectedField = getListInner_field("selected", new JavaType("Integer")).build(); classBuilder.addField(listField); classBuilder.addField(selectedField); // Adds getter/setter for list field classBuilder.addMethod(getListInner_getter(listField)); classBuilder.addMethod(getListInner_setter(listField)); // Adds getter/setter for selected field classBuilder.addMethod(getListInner_getter(selectedField)); classBuilder.addMethod(getListInner_setter(selectedField)); // Return generated class return classBuilder.build(); }
From source file:fr.imag.model2roo.addon.graph.GraphOperationsImpl.java
@Override public void newEntity(final JavaType name, final JavaType superClass, final boolean isAbstract) { int modifier; String entityId;// ww w . jav a 2 s . c o m GraphProvider graphProvider; FieldMetadataBuilder fieldBuilder; ClassOrInterfaceTypeDetails entityDetails; ClassOrInterfaceTypeDetails superClassDetails; ClassOrInterfaceTypeDetailsBuilder entityBuilder; // Class modifier modifier = Modifier.PUBLIC; if (isAbstract) { modifier = Modifier.ABSTRACT; } // Create entity class entityId = PhysicalTypeIdentifier.createIdentifier(name, pathResolver.getFocusedPath(Path.SRC_MAIN_JAVA)); entityBuilder = new ClassOrInterfaceTypeDetailsBuilder(entityId, modifier, name, PhysicalTypeCategory.CLASS); // Base class if (!superClass.equals(OBJECT)) { superClassDetails = typeLocationService.getTypeDetails(superClass); if (superClassDetails != null) { entityBuilder.setSuperclass(new ClassOrInterfaceTypeDetailsBuilder(superClassDetails)); } } entityBuilder.setExtendsTypes(Arrays.asList(superClass)); // Associate appropriate annotations graphProvider = this.getCurrentGraphProvider(); entityBuilder.setAnnotations(graphProvider.getClassAnnotations()); entityBuilder.addAnnotation(ROO_JAVA_BEAN_BUILDER); entityBuilder.addAnnotation(ROO_TO_STRING_BUILDER); typeManagementService.createOrUpdateTypeOnDisk(entityBuilder.build()); // Add id field entityDetails = typeLocationService.getTypeDetails(name); fieldBuilder = new FieldMetadataBuilder(entityDetails.getDeclaredByMetadataId(), Modifier.PRIVATE, graphProvider.getIdAnnotations(), new JavaSymbolName("nodeId"), JavaType.LONG_OBJECT); typeManagementService.addField(fieldBuilder.build()); }
From source file:org.apache.ambari.server.utils.TestShellCommandUtil.java
public void testResultsClassIsPublic() throws Exception { Class resultClass = ShellCommandUtil.Result.class; assertEquals(Modifier.PUBLIC, resultClass.getModifiers() & Modifier.PUBLIC); for (Method method : resultClass.getMethods()) { assertEquals(method.getName(), Modifier.PUBLIC, (method.getModifiers() & Modifier.PUBLIC)); }/*from www . ja v a 2 s. c o m*/ }
From source file:org.codehaus.griffon.ast.GriffonASTUtils.java
public static void injectProperty(ClassNode classNode, String propertyName, Class propertyClass, Object value) { final boolean hasProperty = hasOrInheritsProperty(classNode, propertyName); if (!hasProperty) { // inject into furthest relative // ClassNode parent = getFurthestParent(classNode); Expression initialExpression = null; if (value != null) initialExpression = new ConstantExpression(value); classNode.addProperty(propertyName, Modifier.PUBLIC, new ClassNode(propertyClass), initialExpression, null, null);/*from w w w.j a v a2s.c om*/ } }
From source file:permissionhelper.PermissionHelper.java
/** * Invoke a method with annotation PermissionGranted. * * @param obj//ww w . j a va 2 s .c o m * @param permission */ private void invokeGrantedMethod(Object obj, String permission) { Class clazz = obj.getClass(); PermissionGranted permissionGranted; for (Method method : clazz.getMethods()) { if (method.isAnnotationPresent(PermissionGranted.class)) { permissionGranted = method.getAnnotation(PermissionGranted.class); if (permissionGranted.permission().equals(permission)) { if (method.getModifiers() != Modifier.PUBLIC) { throw new IllegalArgumentException( String.format("Annotation method %s must be public.", method)); } if (method.getParameterTypes().length > 0) { throw new RuntimeException(String.format("Cannot execute non-void method %s.", method)); } try { method.invoke(obj); } catch (Exception e) { e.printStackTrace(); } } } } }
From source file:com.redhat.rhn.frontend.xmlrpc.api.ApiHandler.java
/** * Lists all available api calls for the specified namespace * @param loggedInUser The current user/*from w w w . ja v a 2 s . c o m*/ * @param namespace namespace of interest * @return a map containing list of api calls for every namespace * @throws ClassNotFoundException if namespace isn't valid * * @xmlrpc.doc Lists all available api calls for the specified namespace * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("string", "namespace") * @xmlrpc.returntype * #struct("method_info") * #prop_desc("string", "name", "method name") * #prop_desc("string", "parameters", "method parameters") * #prop_desc("string", "exceptions", "method exceptions") * #prop_desc("string", "return", "method return type") * #struct_end() */ public Map getApiNamespaceCallList(User loggedInUser, String namespace) throws ClassNotFoundException { Class<? extends BaseHandler> handlerClass = new HandlerFactory().getHandler(namespace).getClass(); Map<String, Map<String, Object>> methods = new HashMap<String, Map<String, Object>>(); for (Method method : handlerClass.getDeclaredMethods()) { if (0 != (method.getModifiers() & Modifier.PUBLIC)) { Map<String, Object> methodInfo = new HashMap<String, Object>(); methodInfo.put("name", method.getName()); List<String> paramList = new ArrayList<String>(); String paramListString = ""; for (Type paramType : method.getParameterTypes()) { String paramTypeString = getType(paramType, StringUtils.isEmpty(paramListString)); paramList.add(paramTypeString); paramListString += "_" + paramTypeString; } methodInfo.put("parameters", paramList); Set<String> exceptList = new HashSet<String>(); for (Class<?> exceptClass : method.getExceptionTypes()) { exceptList.add(StringUtil.getClassNameNoPackage(exceptClass)); } methodInfo.put("exceptions", exceptList); methodInfo.put("return", getType(method.getReturnType(), false)); String methodName = namespace + "." + methodInfo.get("name") + paramListString; methods.put(methodName, methodInfo); } } return methods; }
From source file:org.gvnix.web.mvc.binding.roo.addon.addon.metadata.StringTrimmerBinderMetadata.java
/** * Builds the method initStringTrimmerBinder annotated with @InitBinder. * This method registers the StringTrimmerEditor * /* w ww .j ava2 s.com*/ * @param emptyAsNull if true the editor registered will convert empty * Strings to <code>null</code> */ private MethodMetadata getInitStringTrimmerBinderMethod(boolean emptyAsNull) { // Specify the desired method name JavaSymbolName methodName = new JavaSymbolName("initStringTrimmerBinder"); // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); parameterTypes.add(new AnnotatedJavaType(new JavaType("org.springframework.web.bind.WebDataBinder"), new ArrayList<AnnotationMetadata>())); // Check if a method with the same name already exists in the // target type MethodMetadata method = methodExists(methodName); if (method != null) { // If it already exists, just return the method and omit its // generation via the ITD return method; } // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName("binder")); // Define method annotations AnnotationMetadataBuilder initBinder = new AnnotationMetadataBuilder( new JavaType("org.springframework.web.bind.annotation.InitBinder")); List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); annotations.add(initBinder); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); JavaType stringTrimmerEditor = new JavaType( "org.springframework.beans.propertyeditors.StringTrimmerEditor"); bodyBuilder.appendFormalLine("binder.registerCustomEditor(String.class, new " .concat(stringTrimmerEditor.getNameIncludingTypeParameters(false, builder.getImportRegistrationResolver())) .concat("(").concat(String.valueOf(emptyAsNull)).concat("));")); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName, JavaType.VOID_PRIMITIVE, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:com.hihframework.core.utils.ReflectUtil.java
public static final Method[] getPublicMethods(Object obj, String prefix) { return getMethods(obj, Modifier.PUBLIC, prefix); }