List of usage examples for com.google.gwt.core.ext.typeinfo JAbstractMethod isPrivate
boolean isPrivate();
From source file:com.artemis.gwtref.gen.ReflectionCacheSourceCreator.java
License:Apache License
private void printMethods(JClassType c, String varName, String methodType, JAbstractMethod[] methodTypes) { if (methodTypes != null) { pb(varName + "." + methodType.toLowerCase() + "s = new " + methodType + "[] {"); for (JAbstractMethod m : methodTypes) { MethodStub stub = new MethodStub(); stub.isPublic = m.isPublic(); stub.enclosingType = getType(c); if (m.isMethod() != null) { stub.isMethod = true;/*from w w w . jav a 2 s . com*/ stub.returnType = getType(m.isMethod().getReturnType()); stub.isStatic = m.isMethod().isStatic(); stub.isAbstract = m.isMethod().isAbstract(); stub.isNative = m.isMethod().isAbstract(); stub.isFinal = m.isMethod().isFinal(); } else { if (m.isPrivate() || m.isDefaultAccess()) { logger.log(Type.INFO, "Skipping non-visible constructor for class " + c.getName()); continue; } if (m.getEnclosingType().isFinal() && !m.isPublic()) { logger.log(Type.INFO, "Skipping non-public constructor for final class" + c.getName()); continue; } stub.isConstructor = true; stub.returnType = stub.enclosingType; } stub.jnsi = ""; stub.methodId = nextId(); stub.name = m.getName(); methodStubs.add(stub); String methodAnnotations = getAnnotations(m.getDeclaredAnnotations()); pb("new " + methodType + "(\"" + m.getName() + "\", "); pb(stub.enclosingType + ", "); pb(stub.returnType + ", "); pb("new Parameter[] {"); if (m.getParameters() != null) { for (JParameter p : m.getParameters()) { stub.parameterTypes.add(getType(p.getType())); stub.jnsi += p.getType().getErasedType().getJNISignature(); pb("new Parameter(\"" + p.getName() + "\", " + getType(p.getType()) + ", \"" + p.getType().getJNISignature() + "\"), "); } } pb("}, "); pb(stub.isAbstract + ", " + stub.isFinal + ", " + stub.isStatic + ", " + m.isDefaultAccess() + ", " + m.isPrivate() + ", " + m.isProtected() + ", " + m.isPublic() + ", " + stub.isNative + ", " + m.isVarArgs() + ", " + stub.isMethod + ", " + stub.isConstructor + ", " + stub.methodId + ", " + methodAnnotations + "),"); } pb("};"); } }
From source file:com.badlogic.gwtref.gen.ReflectionCacheSourceCreator.java
License:Apache License
private void createTypeInvokables(JClassType c, String varName, String methodType, JAbstractMethod[] methodTypes) { if (methodTypes != null && methodTypes.length > 0) { pb(varName + "." + methodType.toLowerCase() + "s = new " + methodType + "[] {"); for (JAbstractMethod m : methodTypes) { MethodStub stub = new MethodStub(); stub.isPublic = m.isPublic(); stub.enclosingType = getType(c); if (m.isMethod() != null) { stub.isMethod = true;/*w w w. j a va 2 s. c o m*/ stub.returnType = getType(m.isMethod().getReturnType()); stub.isStatic = m.isMethod().isStatic(); stub.isAbstract = m.isMethod().isAbstract(); stub.isNative = m.isMethod().isAbstract(); stub.isFinal = m.isMethod().isFinal(); } else { if (m.isPrivate() || m.isDefaultAccess()) { logger.log(Type.INFO, "Skipping non-visible constructor for class " + c.getName()); continue; } if (m.getEnclosingType().isFinal() && !m.isPublic()) { logger.log(Type.INFO, "Skipping non-public constructor for final class" + c.getName()); continue; } stub.isConstructor = true; stub.returnType = stub.enclosingType; } stub.jnsi = ""; stub.methodId = nextInvokableId++; stub.name = m.getName(); methodStubs.add(stub); pbn(" new " + methodType + "(\"" + m.getName() + "\", "); pbn(stub.enclosingType + ", "); pbn(stub.returnType + ", "); if (m.getParameters() != null && m.getParameters().length > 0) { pbn("new Parameter[] {"); for (JParameter p : m.getParameters()) { stub.parameterTypes.add(getType(p.getType())); stub.jnsi += p.getType().getErasedType().getJNISignature(); String paramName = (p.getName() + "__" + p.getType().getErasedType().getJNISignature()) .replaceAll("[/;\\[\\]]", "_"); String paramInstantiation = "new Parameter(\"" + p.getName() + "\", " + getType(p.getType()) + ", \"" + p.getType().getJNISignature() + "\")"; parameterName2ParameterInstantiation.put(paramName, paramInstantiation); pbn(paramName + "(), "); } pbn("}, "); } else { pbn("EMPTY_PARAMETERS,"); } pb(stub.isAbstract + ", " + stub.isFinal + ", " + stub.isStatic + ", " + m.isDefaultAccess() + ", " + m.isPrivate() + ", " + m.isProtected() + ", " + m.isPublic() + ", " + stub.isNative + ", " + m.isVarArgs() + ", " + stub.isMethod + ", " + stub.isConstructor + ", " + stub.methodId + "," + getAnnotations(m.getDeclaredAnnotations()) + "),"); } pb("};"); } }
From source file:com.github.nmorel.gwtjackson.rebind.BeanJsonDeserializerCreator.java
License:Apache License
private MethodSpec buildInstanceBuilderCreateMethod() { JAbstractMethod method = beanInfo.getCreatorMethod().get(); MethodSpec.Builder builder = MethodSpec.methodBuilder("create").addModifiers(Modifier.PRIVATE) .returns(typeName(beanInfo.getType())); StringBuilder parametersNameBuilder = new StringBuilder(); int index = 0; for (Map.Entry<String, JParameter> parameterEntry : beanInfo.getCreatorParameters().entrySet()) { if (index > 0) { parametersNameBuilder.append(", "); }/*from w w w .j a va 2 s.c o m*/ PropertyInfo property = properties.get(parameterEntry.getKey()); String variableName = String.format(INSTANCE_BUILDER_VARIABLE_FORMAT, index++); builder.addParameter(typeName(property.getType()), variableName); parametersNameBuilder.append(variableName); } String parametersName = parametersNameBuilder.toString(); if (method.isPrivate() || (!method.isPublic() && !mapperInfo.isSamePackage())) { // private method, we use jsni builder.addModifiers(Modifier.NATIVE); builder.addCode(JsniCodeBlockBuilder.builder() .addStatement("return $L($L)", method.getJsniSignature(), parametersName).build()); } else { if (null != method.isConstructor()) { builder.addStatement("return new $T($L)", typeName(beanInfo.getType()), parametersName); } else { builder.addStatement("return $T.$L($L)", typeName(beanInfo.getType()), method.getName(), parametersName); } } return builder.build(); }
From source file:fr.onevu.gwt.uibinder.rebind.JClassTypeAdapter.java
License:Apache License
/** * Adds expectations common to all method types (methods and constructors). * * @param realMember the java method//from w ww . j a va 2 s . c om * @param member the mock GWT method * @param enclosingType the type to which the method belongs */ private void addCommonAbstractMethodBehaviour(Member realMember, JAbstractMethod member, JClassType enclosingType) { // Attributes int modifiers = realMember.getModifiers(); expect(member.isPublic()).andStubReturn(Modifier.isPublic(modifiers)); expect(member.isProtected()).andStubReturn(Modifier.isProtected(modifiers)); expect(member.isPrivate()).andStubReturn(Modifier.isPrivate(modifiers)); expect(member.getName()).andStubReturn(realMember.getName()); expect(member.getEnclosingType()).andStubReturn(enclosingType); }