private String getElementTypes (JField f) { StringBuilder b = new StringBuilder(); JParameterizedType params = f.getType().isParameterized(); if (params != null) { JClassType[] typeArgs = params.getTypeArgs(); b.append("new Class[] {"); for (JClassType typeArg : typeArgs) { if (typeArg.isWildcard() != null) b.append("null"); else if (!isVisible(typeArg)) b.append("null"); else if (typeArg.isClassOrInterface() != null) b.append(typeArg.isClassOrInterface().getQualifiedSourceName()).append(".class"); else if (typeArg.isParameterized() != null) b.append(typeArg.isParameterized().getQualifiedBinaryName()).append(".class"); else b.append("null"); b.append(", "); } b.append("}"); return b.toString(); } return "null"; }
private String getElementTypes (JField f) { StringBuilder b = new StringBuilder(); JParameterizedType params = f.getType().isParameterized(); if (params != null) { JClassType[] typeArgs = params.getTypeArgs(); b.append("new Class[] {"); for (JClassType typeArg : typeArgs) { if (typeArg.isWildcard() != null) b.append("null"); else if (!isVisible(typeArg)) b.append("null"); else if (typeArg.isClassOrInterface() != null) b.append(typeArg.isClassOrInterface().getQualifiedSourceName()).append(".class"); else if (typeArg.isParameterized() != null) b.append(typeArg.isParameterized().getQualifiedBinaryName()).append(".class"); else b.append("null"); b.append(", "); } b.append("}"); return b.toString(); } return "null"; }
if (fields != null) { for (JField field : fields) { gatherTypes(field.getType().getErasedType(), types);
if (fields != null) { for (JField field : fields) { gatherTypes(field.getType().getErasedType(), types);
for (JField f : c.getFields()) { String enclosingType = getType(c); String fieldType = getType(f.getType()); int setterGetter = nextSetterGetterId++; String elementType = getElementTypes(f);
for (JField f : c.getFields()) { String enclosingType = getType(c); String fieldType = getType(f.getType()); int setterGetter = nextSetterGetterId++; String elementType = getElementTypes(f);
@Override public JType getType() { return field.getType(); }
public InjectModelCreator(JField modelField) { this.modelField = modelField; this.fieldType = modelField.getType(); if (this.fieldType instanceof JParameterizedType) { JParameterizedType paramType = (JParameterizedType) this.fieldType; this.beanType = paramType.getTypeArgs()[0]; } else { throw new RuntimeException("modelField can not be injected as Model"); } }
public String generateFieldMapperGenerator(TypeOracle oracle, JField targetWidget, JType targetType, JField targetEntityMember, JField targetEntityField) { InputStream istream = this.getClass().getResourceAsStream("TextBoxFMGenerator.mv"); Map<String, Object> vars = new HashMap<String, Object>(); vars.put("typeOracle", oracle); vars.put("targetWidget", targetWidget.getType().isClassOrInterface().getQualifiedSourceName()); vars.put("targetType", targetType.isClassOrInterface().getQualifiedSourceName()); vars.put("fieldType", targetEntityMember.getType().isClassOrInterface().getQualifiedSourceName()); vars.put("fieldName", targetEntityMember.getName()); return (String) TemplateRuntime.eval(istream, null, new MapVariableResolverFactory(vars), null); }
@Override public void writeConstructor(SourceWriter srcWriter) { srcWriter.println("%s = GWT.create(%s.class);", this.resourceField.getName(), this.resourceField.getType().getQualifiedSourceName()); } }
boolean processField(JField field) { return !field.isPrivate() && !field.isStatic() && field.getType().isClass() != null && field.getAnnotation(WithElementId.class) != null; }
@Override public String toString() { JType type = field.getType(); JClassType enclosingType = field.getEnclosingType(); return "'" + type.getParameterizedQualifiedSourceName() + "' is reachable from field '" + field.getName() + "' of type '" + enclosingType.getParameterizedQualifiedSourceName() + "'"; } };
@Override public String toString() { JType type = field.getType(); JClassType enclosingType = field.getEnclosingType(); return "'" + type.getParameterizedQualifiedSourceName() + "' is reachable from field '" + field.getName() + "' of type '" + enclosingType.getParameterizedQualifiedSourceName() + "'"; } };
@Test public void processField_primitiveType() { JClassType fieldType = mock(JClassType.class); when(field.getType()).thenReturn(fieldType); when(fieldType.isClass()).thenReturn(null); verifyProcessFieldReturns(false); }
void stubPassingField(JField field, JClassType fieldType, String fieldName) { WithElementId idAnnotation = mock(WithElementId.class); when(field.isPrivate()).thenReturn(false); when(field.isStatic()).thenReturn(false); when(field.getType()).thenReturn(fieldType); when(field.getName()).thenReturn(fieldName); when(fieldType.isClass()).thenReturn(fieldType); when(field.getAnnotation(WithElementId.class)).thenReturn(idAnnotation); when(idAnnotation.value()).thenReturn(""); //$NON-NLS-1$ when(idAnnotation.processType()).thenReturn(true); }
private void overrideAllGetters(){ JClassTypeHelper helper = new JClassTypeHelper(type); for(JField field:helper.getAllFields()){ if (ignore(field)==false){ Field f = new Field(Visibility.PRIVATE, JTypeHelper.getClass(field.getType()), field.getName()); f.setJtype(field.getType()); Method getter = f.getGetter(true,"_proxy"); composerHelper.addMethod(getter); } } }
JType getElementType(PropertyDescriptor p, boolean useField) { if (useField) { return jClass.findField(p.getPropertyName()).getType(); } else { return jClass.findMethod(GwtSpecificValidatorCreator.asGetter(p), GwtSpecificValidatorCreator.NO_ARGS).getReturnType(); } }