private boolean isMutator(Method<O, ?> method) { if (method.isConstructor()) { return false; } return method.isReturnTypeVoid() && method.getParameters().size() == 1 && Strings.areEqual(method.getName(), methodName("set", name)); }
private boolean isMutator(Method<O, ?> method) { return extractPropertyName(method) != null && method.getParameters().size() == 1 && method.isReturnTypeVoid(); }
@Override public boolean hasMethodSignature(final Method<?, ?> method) { for (MethodSource<O> local : getMethods()) { if (local.getName().equals(method.getName())) { Iterator<ParameterSource<O>> localParams = local.getParameters().iterator(); for (Parameter<? extends JavaType<?>> methodParam : method.getParameters()) { if (localParams.hasNext() && Strings.areEqual(localParams.next().getType().getName(), methodParam.getType().getName())) { continue; } return false; } return !localParams.hasNext(); } } return false; }
private void addMethod(org.kie.workbench.common.services.datamodeller.core.JavaClass javaClass, Method method, ClassTypeResolver classTypeResolver) throws ClassNotFoundException, ModelDriverException { List<Parameter> parameters = method.getParameters(); if (method.getReturnType() != null) { returnType = new org.kie.workbench.common.services.datamodeller.core.impl.TypeImpl( resolveTypeName(classTypeResolver, method.getReturnType().getName()), resolveTypeArguments(method.getReturnType().getTypeArguments())); if (method.getVisibility() != null) { visibility = DriverUtils.buildVisibility(method.getVisibility()); MethodImpl dataObjectMethod = new MethodImpl(method.getName(), modelParameters, method.getBody(), returnType, visibility); List<AnnotationSource<JavaClassSource>> annotations = method.getAnnotations(); if (annotations != null) { for (AnnotationSource annotation : annotations) {
if (member instanceof Method) type = ((Method<?, ?>) member).getReturnType().getQualifiedName(); if (name.startsWith("get")) if (method.getParameters().size() == 0 && (method.getReturnType() != null && type.equals(method.getReturnType().getQualifiedName()))) if (method.getName().toLowerCase().contains(name.toLowerCase())) result = method.getName() + "()"; break;
if (method.isStatic()) if (!method.isPublic()) if (!method.getParameters().isEmpty()) String returnType = method.getReturnType() != null ? method.getReturnType().getQualifiedName() : null;
/** * Returns whether the given method is a 'getter' method. * * @param method a parameterless method that returns a non-void * @return the property name */ protected String isGetter(final Method<?, ?> method) { String methodName = method.getName(); String propertyName; if (methodName.startsWith(ClassUtils.JAVABEAN_GET_PREFIX)) { propertyName = methodName.substring(ClassUtils.JAVABEAN_GET_PREFIX.length()); } else if (methodName.startsWith(ClassUtils.JAVABEAN_IS_PREFIX) && method.getReturnType() != null && boolean.class.equals(method.getReturnType().getQualifiedName())) { // As per section 8.3.2 (Boolean properties) of The JavaBeans API specification, 'is' // only applies to boolean (little 'b') propertyName = methodName.substring(ClassUtils.JAVABEAN_IS_PREFIX.length()); } else { return null; } return StringUtils.decapitalize(propertyName); }
if (method.isStatic()) if (!method.isPublic()) List<? extends Parameter<?>> parameters = method.getParameters();
@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; }
@Override @SuppressWarnings("unchecked") public O removeMethod(final Method<O, ?> method) { getDeclaration().bodyDeclarations().remove(method.getInternal()); return (O) this; }
@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 hasMethodSignature(final Method<?, ?> method) { for (MethodSource<Body> local : getMethods()) { if (local.getName().equals(method.getName())) { final Iterator<ParameterSource<Body>> localParams = local.getParameters().iterator(); for (Parameter<? extends JavaType<?>> methodParam : method.getParameters()) { if (localParams.hasNext() && Strings.areEqual(localParams.next().getType().getName(), methodParam.getType().getName())) { continue; } return false; } return !localParams.hasNext(); } } return false; }
if (method.isStatic()) if (!method.isPublic()) if (!method.getParameters().isEmpty()) String returnType = method.getReturnType() != null ? method.getReturnType().getQualifiedName() : null;
/** * Returns whether the given method is a 'getter' method. * * @param method a parameterless method that returns a non-void * @return the property name */ protected String isGetter(final Method<?, ?> method) { String methodName = method.getName(); String propertyName; if (methodName.startsWith(ClassUtils.JAVABEAN_GET_PREFIX)) { propertyName = methodName.substring(ClassUtils.JAVABEAN_GET_PREFIX.length()); } else if (methodName.startsWith(ClassUtils.JAVABEAN_IS_PREFIX) && method.getReturnType() != null && boolean.class.equals(method.getReturnType().getQualifiedName())) { // As per section 8.3.2 (Boolean properties) of The JavaBeans API specification, 'is' // only applies to boolean (little 'b') propertyName = methodName.substring(ClassUtils.JAVABEAN_IS_PREFIX.length()); } else { return null; } return StringUtils.decapitalize(propertyName); }
private boolean isAccessor(Method<O, ?> method) { return extractPropertyName(method) != null && method.getParameters().isEmpty() && !method.isReturnTypeVoid(); }
if (method.isStatic()) if (!method.isPublic()) List<? extends Parameter<?>> parameters = method.getParameters();
@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; }
@Override public Body removeMethod(final Method<Body, ?> method) { getBody().bodyDeclarations().remove(method.getInternal()); return this; }