@Override public boolean hasField(final String name) { for (Field<Body> field : getFields()) { if (field.getName().equals(name)) { return true; } } return false; }
protected boolean canAddFieldToToString(Field<JavaClassSource> field) { return !field.isStatic() && !field.isTransient() && !field.getType().isArray(); }
@Override public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) { org.jboss.forge.roaster.model.Annotation<?> annotation = null; // https://issues.jboss.org/browse/FORGE-439: support annotations on readMethod if (this.readMethod != null) { annotation = this.readMethod.getAnnotation(annotationClass.getName()); } if (annotation == null && this.privateField != null) { annotation = this.privateField.getAnnotation(annotationClass.getName()); } if (annotation != null) { T annotationProxy = AnnotationProxy.newInstance(annotation); return annotationProxy; } return null; }
@Override public String getGenericType() { if (this.readMethod != null) { @SuppressWarnings({ "unchecked", "rawtypes" }) List<Type<?>> typeArguments = (List) this.readMethod.getReturnType().getTypeArguments(); if (!typeArguments.isEmpty()) { return typeArguments.get(0).getQualifiedName(); } } if (this.privateField != null) { @SuppressWarnings({ "unchecked", "rawtypes" }) List<Type<?>> typeArguments = (List) this.privateField.getType().getTypeArguments(); if (!typeArguments.isEmpty()) { return typeArguments.get(0).getQualifiedName(); } } return null; }
private void addField(Field<Body> field) { final List<BodyDeclaration> bodyDeclarations = getBody().bodyDeclarations(); int idx = 0; for (BodyDeclaration bodyDeclaration : bodyDeclarations) { if (!(bodyDeclaration instanceof FieldDeclaration)) { break; } idx++; } bodyDeclarations.add(idx, (BodyDeclaration) ((VariableDeclarationFragment) field.getInternal()).getParent()); }
@Override public String getGenericType() { if (this.readMethod != null) { @SuppressWarnings({ "unchecked", "rawtypes" }) List<Type<?>> typeArguments = (List) this.readMethod.getReturnType().getTypeArguments(); if (!typeArguments.isEmpty()) { return typeArguments.get(0).getQualifiedName(); } } if (this.privateField != null) { @SuppressWarnings({ "unchecked", "rawtypes" }) List<Type<?>> typeArguments = (List) this.privateField.getType().getTypeArguments(); if (!typeArguments.isEmpty()) { return typeArguments.get(0).getQualifiedName(); } } return null; }
private void addField(Field<Body> field) { final List<BodyDeclaration> bodyDeclarations = getBody().bodyDeclarations(); int idx = 0; for (BodyDeclaration bodyDeclaration : bodyDeclarations) { if (!(bodyDeclaration instanceof FieldDeclaration)) { break; } idx++; } bodyDeclarations.add(idx, (BodyDeclaration) ((VariableDeclarationFragment) field.getInternal()).getParent()); }
@Override public boolean hasField(final String name) { for (Field<Body> field : getFields()) { if (field.getName().equals(name)) { return true; } } return false; }
public static String resolveIdType(JavaClass<?> entity) { for (Member<?> member : entity.getMembers()) { if (member.hasAnnotation(Id.class)) { if (member instanceof Method) { return ((Method<?, ?>) member).getReturnType().getName(); } if (member instanceof Field) { return ((Field<?>) member).getType().getName(); } } } return "Object"; } }
@SuppressWarnings("unchecked") private void addField(Field<O> field) { List<Object> bodyDeclarations = getDeclaration().bodyDeclarations(); int idx = 0; for (Object object : bodyDeclarations) { if (!(object instanceof FieldDeclaration)) { break; } idx++; } bodyDeclarations.add(idx, ((VariableDeclarationFragment) field.getInternal()).getParent()); }
@Override public <T extends Annotation> T getAnnotation(final Class<T> annotationClass) { org.jboss.forge.roaster.model.Annotation<?> annotation = null; // https://issues.jboss.org/browse/FORGE-439: support annotations on readMethod if (this.readMethod != null) { annotation = this.readMethod.getAnnotation(annotationClass.getName()); } if (annotation == null && this.privateField != null) { annotation = this.privateField.getAnnotation(annotationClass.getName()); } if (annotation != null) { T annotationProxy = AnnotationProxy.newInstance(annotation); return annotationProxy; } return null; }
@Override public boolean hasField(final String name) { for (Field<Body> field : getFields()) { if (field.getName().equals(name)) { return true; } } return false; }
type = ((Field<?>) member).getType().getQualifiedName();
@SuppressWarnings("unchecked") private void addField(Field<O> field) { List<Object> bodyDeclarations = getBodyDeclaration().bodyDeclarations(); int idx = 0; for (Object object : bodyDeclarations) { if (!(object instanceof FieldDeclaration)) { break; } idx++; } bodyDeclarations.add(idx, ((VariableDeclarationFragment) field.getInternal()).getParent()); }
/** * Removes the field, including its getters and setters and updating toString() * * @param targetClass The class, which field will be removed * @param field The field to be removed */ public void removeField(final JavaClassSource targetClass, final Field<JavaClassSource> field) { PropertySource<JavaClassSource> property = targetClass.getProperty(field.getName()); property.setMutable(false).setAccessible(false); targetClass.removeProperty(property); updateToString(targetClass); }
@SuppressWarnings("unchecked") private void addField(Field<Body> field) { final List<BodyDeclaration> bodyDeclarations = getBody().bodyDeclarations(); int idx = 0; for (BodyDeclaration bodyDeclaration : bodyDeclarations) { if (!(bodyDeclaration instanceof FieldDeclaration)) { break; } idx++; } bodyDeclarations.add(idx, (BodyDeclaration) ((VariableDeclarationFragment) field.getInternal()).getParent()); }
propertyName = privateField.getName();
@SuppressWarnings("unchecked") private void addField(Field<O> field) { List<Object> bodyDeclarations = getBodyDeclaration().bodyDeclarations(); int idx = 0; for (Object object : bodyDeclarations) { if (!(object instanceof FieldDeclaration)) { break; } idx++; } bodyDeclarations.add(idx, ((VariableDeclarationFragment) field.getInternal()).getParent()); }
propertyName = privateField.getName();