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.gva.security.providers.safe.SafeSecurityProviderAuthenticationFilterMetadata.java
/** * Gets all getters methods. <br>//from ww w . jav a 2 s . c o m * * @return */ private MethodMetadata getGetterMethod(String propertyName, JavaType returnType) { // Define method parameter types List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); // Check if a method with the same signature already exists in the // target type String prefix = returnType == JavaType.BOOLEAN_PRIMITIVE ? "is" : "get"; JavaSymbolName propertyMethodName = new JavaSymbolName( prefix.concat(Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1))); final MethodMetadata method = methodExists(propertyMethodName, 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(); buildGetterMethodBody(bodyBuilder, propertyName); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, propertyMethodName, returnType, parameterTypes, parameterNames, bodyBuilder); methodBuilder.setAnnotations(annotations); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata // instance }
From source file:hu.bme.mit.sette.common.model.snippet.SnippetContainer.java
/** * Validates the class and its annotations. * * @param validator//from w w w . j a v a2s .com * a validator * @return the {@link SetteSnippetContainer} annotation */ private SetteSnippetContainer validateClass(final AbstractValidator<?> validator) { // check: "public final class", no superclass, interface, declared // class, exactly one constructor ClassValidator v = new ClassValidator(javaClass); v.type(ClassType.REGULAR_CLASS); v.withModifiers(Modifier.PUBLIC | Modifier.FINAL); v.withoutModifiers(Modifier.ABSTRACT); v.synthetic(false); v.superclass(Object.class).interfaceCount(0).memberClassCount(0); v.declaredConstructorCount(1); // check: only @SetteSnippetContainer SetteSnippetContainer containerAnn = null; AnnotationMap classAnns = SetteAnnotationUtils.getSetteAnnotations(javaClass); containerAnn = (SetteSnippetContainer) classAnns.get(SetteSnippetContainer.class); if (containerAnn == null) { v.addException( "The Java class must have the annotation @" + SetteSnippetContainer.class.getSimpleName()); } else { if (classAnns.size() != 1) { v.addException("The Java class must not have any " + "SETTE annotations other than @" + SetteSnippetContainer.class.getSimpleName()); } if (StringUtils.isBlank(containerAnn.category())) { v.addException( "The category in @" + SetteSnippetContainer.class.getSimpleName() + " must not be blank"); } if (StringUtils.isBlank(containerAnn.goal())) { v.addException( "The goal in @" + SetteSnippetContainer.class.getSimpleName() + " must not be blank"); } if (containerAnn.requiredJavaVersion() == null) { v.addException("The reqired Java version in @" + SetteSnippetContainer.class.getSimpleName() + " must not be null"); } } validator.addChildIfInvalid(v); return containerAnn; }
From source file:org.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderExtLoadWSS4JMetadata.java
/** * Generates constructor method without arguments *//* w w w.j a v a2 s.co m*/ private ConstructorMetadataBuilder getExtLoadWSS4JConst() { // Search for an existing constructor final ConstructorMetadata existingExplicitConstructor = governorTypeDetails.getDeclaredConstructor(null); if (existingExplicitConstructor != null) { // Found an existing no-arg constructor on this class, so return it return new ConstructorMetadataBuilder(existingExplicitConstructor); } // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.appendFormalLine("super();"); // Use the ConstructorMetadataBuilder for easy creation of // MethodMetadata ConstructorMetadataBuilder consBuilder = new ConstructorMetadataBuilder(getId()); // Set the modifier public to constructor consBuilder.setModifier(Modifier.PUBLIC); // Set the body to constructor consBuilder.setBodyBuilder(bodyBuilder); // return a ConstructorMetadataBuilder instance return consBuilder; }
From source file:org.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderPasswordMetadata.java
/** * Gets <code>handle</code> method. <br> * //from ww w . ja v a2s . co m * @return */ private MethodMetadata getHandleMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType.convertFromJavaTypes(CALLBACK_PARAM_ARRAY_TYPE); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(HANDLE_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>(); throwsTypes.add(CALLBACK_EXCEPTION); throwsTypes.add(IO_EXCEPTION); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(CALLBACKS_PARAM); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildHandleMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, HANDLE_METHOD, 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.gvnix.addon.gva.security.providers.safe.SafeSecurityProviderLoginMetadata.java
/** * Gets <code>getAttemptAuthentication</code> method. <br> * /* w w w . j a v a2s.c o m*/ * @return */ private MethodMetadata getCreateLoginMethod() { // Define method parameter types List<AnnotatedJavaType> parameterTypes = AnnotatedJavaType.convertFromJavaTypes(SpringJavaType.MODEL); // Check if a method with the same signature already exists in the // target type final MethodMetadata method = methodExists(CREATE_LOGIN_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>(); AnnotationMetadataBuilder requestMappingAnnotation = new AnnotationMetadataBuilder( SpringJavaType.REQUEST_MAPPING); requestMappingAnnotation.addStringAttribute("value", "/login"); requestMappingAnnotation.addEnumAttribute("method", new JavaType("org.springframework.web.bind.annotation.RequestMethod"), "GET"); annotations.add(requestMappingAnnotation); // Define method throws types List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter names List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); parameterNames.add(new JavaSymbolName("uiModel")); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); buildCreateLoginMethodBody(bodyBuilder); // Use the MethodMetadataBuilder for easy creation of MethodMetadata MethodMetadataBuilder methodBuilder = new MethodMetadataBuilder(getId(), Modifier.PUBLIC, CREATE_LOGIN_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.codehaus.groovy.grails.compiler.injection.DefaultGrailsDomainClassInjector.java
private void addAssociationForKey(String key, List properties, ClassNode classNode) { properties/* www . j a va 2s.c o m*/ .add(new PropertyNode(key, Modifier.PUBLIC, new ClassNode(Set.class), classNode, null, null, null)); }
From source file:org.codehaus.griffon.ast.GriffonASTUtils.java
public static void injectConstant(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 = new ConstantExpression(value); classNode.addProperty(propertyName, Modifier.PUBLIC | Modifier.FINAL, new ClassNode(propertyClass), initialExpression, null, null); }//from w w w . ja va2 s . c o m }
From source file:org.apache.tinkerpop.gremlin.structure.util.StringFactory.java
public static String featureString(final Graph.Features features) { final StringBuilder sb = new StringBuilder("FEATURES"); final Predicate<Method> supportMethods = (m) -> m.getModifiers() == Modifier.PUBLIC && m.getName().startsWith(featuresStartWith) && !m.getName().equals(featuresStartWith); sb.append(LINE_SEPARATOR);/*from w ww .j ava 2 s .c o m*/ Stream.of(Pair.with(Graph.Features.GraphFeatures.class, features.graph()), Pair.with(Graph.Features.VariableFeatures.class, features.graph().variables()), Pair.with(Graph.Features.VertexFeatures.class, features.vertex()), Pair.with(Graph.Features.VertexPropertyFeatures.class, features.vertex().properties()), Pair.with(Graph.Features.EdgeFeatures.class, features.edge()), Pair.with(Graph.Features.EdgePropertyFeatures.class, features.edge().properties())).forEach(p -> { printFeatureTitle(p.getValue0(), sb); Stream.of(p.getValue0().getMethods()).filter(supportMethods).map(createTransform(p.getValue1())) .forEach(sb::append); }); return sb.toString(); }
From source file:blue.lapis.pore.impl.event.PoreEventImplTest.java
private static boolean isDefault(Method method) { // Default methods are public non-abstract instance methods declared in an interface. return ((method.getModifiers() & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC) && method.getDeclaringClass().isInterface(); }
From source file:fr.imag.model2roo.addon.polyglot.PolyglotMetadata.java
private MethodMetadata getSampleMethod() { // Specify the desired method name JavaSymbolName methodName = new JavaSymbolName("sampleMethod"); // Check if a method with the same signature already exists in the target type final MethodMetadata method = methodExists(methodName, new ArrayList<AnnotatedJavaType>()); if (method != null) { // If it already exists, just return the method and omit its generation via the ITD return method; }// w w w. j a va 2 s .c o m // Define method annotations (none in this case) List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(); // Define method throws types (none in this case) List<JavaType> throwsTypes = new ArrayList<JavaType>(); // Define method parameter types (none in this case) List<AnnotatedJavaType> parameterTypes = new ArrayList<AnnotatedJavaType>(); // Define method parameter names (none in this case) List<JavaSymbolName> parameterNames = new ArrayList<JavaSymbolName>(); // Create the method body InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder(); bodyBuilder.appendFormalLine("System.out.println(\"Hello World\");"); // 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); methodBuilder.setThrowsTypes(throwsTypes); return methodBuilder.build(); // Build and return a MethodMetadata instance }