/** * Indicates whether the underlying field or the accessor returns a Java language primitive type. * * @return true if the type of the property is a Java language primitive. */ public boolean isPrimitive() { return (actualField != null && actualField.isPrimitive()) || (accessor != null && accessor.getReturnTypeInspector().isPrimitive()); }
/** * Verifies whether the provided annotation is present on the property. Only fields and accessors are considered. * Mutators/setter methods are ignored. * * @param klass The annotation class whose presence is to be verified * @return true if the annotation is present on the field or the accessor of the property */ public boolean hasAnnotation(Class<? extends Annotation> klass) { return (actualField != null && actualField.hasAnnotation(klass)) || (accessor != null && accessor.hasAnnotation(klass)); }
private void createCopyConstructor() { dto.addImport(entity.getQualifiedName()); dto.addImport(EntityManager.class); copyCtor = dto.addMethod() .setConstructor(true) .setPublic() .setParameters("final " + entity.getName() + " entity"); }
private void createJPAAssembler() { assembleJPA = dto.addMethod() .setName("fromDTO") .setReturnType(entity.getName()) .setPublic() .setParameters(entity.getName() + " entity, EntityManager em"); assembleJPABuilder.append("if(entity == null) { entity = new " + entity.getName() + "(); }"); }
private void displayGeneratedValueFieldWarningMsg(JavaClass klass, Field<?> field) { ShellMessages.warn(writer, "A field [" + field.getName() + "] having the @GeneratedValue annotation was chosen. The generated equals() and hashCode() methods for the class [" + klass.getName() + "] may be incorrect."); }
private void createDefaultConstructor() { Method<JavaClass> ctor = dto.addMethod(); ctor.setConstructor(true); ctor.setPublic(); ctor.setBody(""); }
private String resolveIdType(JavaClass entity) { for (Member<JavaClass, ?> member : entity.getMembers()) { if (member.hasAnnotation(Id.class)) { if (member instanceof Method) { return ((Method<?>) member).getReturnType(); } if (member instanceof Field) { return ((Field<?>) member).getType(); } } } return "Object"; }
private void addInitializerFromDTO(JPAProperty property, JavaClass dtoClass) { String fieldName = property.getName(); String fieldGetter = property.getAccessor().getName(); String dtoType = dtoClass.getName(); copyCtorBuilder.append("this." + fieldName + " = " + "new " + dtoType + "(entity." + fieldGetter + "());"); }
private void overwriteMethods(JavaClass entity) { if (entity.hasMethodSignature("equals", Object.class)) { entity.removeMethod(entity.getMethod("equals", Object.class)); } if (entity.hasMethodSignature("hashCode")) { entity.removeMethod(entity.getMethod("hashCode")); } }
public DTOClassBuilder setPackage(String dtoPackage) { dto.setPackage(dtoPackage); return this; }
private void initName() { dtoClassName = (topLevel ? "" : "Nested") + entity.getName() + "DTO"; }
public String getQualifiedClassNameForMatch() { if(javaSource != null) { return javaSource.getQualifiedName(); } return null; }
@Override public String getName() { return enumConstant.getName(); }
@Override public String getName() { return member.getName(); }
private void setConstraintMessage(Annotation<JavaClass> annotation, String message) { if (message != null) { annotation.setStringValue("message", message); } }
/** * Indicates whether the property is transient or not. * * @return true if the underlying field of the property is transient */ public boolean isTransient() { return actualField != null && actualField.isTransient(); }