Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get rid of commons-lang #370

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies {
compileOnly "org.springframework.boot:spring-boot-starter-actuator"
compileOnly "org.springframework.boot:spring-boot-autoconfigure"
compileOnly "org.springframework.boot:spring-boot-starter-tomcat"
compileOnly "org.grails:grails-dependencies"
compileOnly "org.grails:grails-plugin-controllers"
compileOnly "org.grails.plugins:gsp:${grailsVersion}"

testImplementation "org.grails:grails-web-testing-support"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

package grails.plugin.formfields

import grails.core.GrailsApplication
import grails.util.GrailsStringUtils
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import groovy.xml.MarkupBuilder
import groovy.xml.MarkupBuilderHelper
import org.apache.commons.lang.StringUtils
import org.grails.buffer.FastStringWriter
import org.grails.datastore.mapping.model.MappingContext
import org.grails.datastore.mapping.model.PersistentEntity
Expand Down Expand Up @@ -713,7 +712,7 @@ class FormFieldsTagLib {
return g.field(attrs + [type: "file"])
} else if (model.type in [TimeZone, Currency, Locale]) {
if (!model.required) attrs.noSelection = ["": ""]
return g."${StringUtils.uncapitalize(model.type.simpleName)}Select"(attrs)
return g."${GrailsStringUtils.uncapitalize(model.type.simpleName)}Select"(attrs)
} else {
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ import grails.core.GrailsApplication
import grails.core.GrailsDomainClass
import grails.gorm.Entity
import grails.gorm.validation.ConstrainedProperty
import grails.util.GrailsClassUtils
import grails.util.GrailsNameUtils
import grails.validation.Validateable
import grails.web.databinding.WebDataBinding
import groovy.transform.Canonical
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import groovy.transform.Memoized
import groovy.transform.TupleConstructor
import org.apache.commons.lang.ClassUtils
import org.grails.datastore.gorm.GormEntity
import org.grails.datastore.gorm.GormValidateable
import org.grails.datastore.mapping.dirty.checking.DirtyCheckable
Expand Down Expand Up @@ -125,17 +124,22 @@ class BeanPropertyAccessorImpl implements BeanPropertyAccessor {
!errors.isEmpty()
}

@CompileDynamic
private static List<Class> getSuperclassesAndInterfaces(Class type) {
private static List<Class<?>> getAllSuperclasses(Class<?> clazz) {
List<Class<?>> superclasses = []
Class<?> current = clazz
while ((current = current.getSuperclass()) != null) {
superclasses.add(current)
}
return superclasses
}

protected static List<Class> getSuperclassesAndInterfaces(Class type) {
List<Class> superclasses = []
superclasses.addAll(ClassUtils.getAllSuperclasses(ClassUtils.primitiveToWrapper(type)))
for (Object it in ClassUtils.getAllInterfaces(type)) {
Class interfaceCls = (Class) it
superclasses.addAll(getAllSuperclasses(org.springframework.util.ClassUtils.resolvePrimitiveIfNecessary(type)))
for (Class<?> interfaceCls : GrailsClassUtils.getAllInterfacesForClass(type)) {
String name = interfaceCls.name
if (name.indexOf('$') == -1) {
if (interfaceCls.package != GormEntity.package) {
superclasses.add(interfaceCls)
}
if (!name.contains('$') && interfaceCls.package != GormEntity.package) {
superclasses.add(interfaceCls)
}
}
superclasses.removeAll([Object, GroovyObject, Serializable, Cloneable, Comparable, WebDataBinding, DirtyCheckable, Entity])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
package grails.plugin.formfields

import grails.core.GrailsDomainClass
import grails.gorm.Entity
import grails.util.GrailsNameUtils
import grails.validation.Validateable
import grails.web.databinding.WebDataBinding
import groovy.transform.Canonical
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import groovy.transform.ToString
import org.apache.commons.lang.ClassUtils
import org.grails.datastore.gorm.GormEntity
import org.grails.datastore.gorm.GormValidateable
import org.grails.datastore.mapping.dirty.checking.DirtyCheckable
import org.grails.datastore.mapping.model.PersistentEntity
import org.grails.datastore.mapping.model.PersistentProperty
import org.grails.scaffolding.model.property.Constrained
Expand Down Expand Up @@ -72,12 +66,12 @@ class DelegatingBeanPropertyAccessorImpl implements BeanPropertyAccessor {

@Override
List<Class> getBeanSuperclasses() {
getSuperclassesAndInterfaces(beanType)
BeanPropertyAccessorImpl.getSuperclassesAndInterfaces(beanType)
}

@Override
List<Class> getPropertyTypeSuperclasses() {
getSuperclassesAndInterfaces(propertyType)
BeanPropertyAccessorImpl.getSuperclassesAndInterfaces(propertyType)
}

@Override
Expand Down Expand Up @@ -142,21 +136,4 @@ class DelegatingBeanPropertyAccessorImpl implements BeanPropertyAccessor {
boolean equals(Object obj) {
this.hashCode() == obj?.hashCode()
}

@CompileDynamic
private List<Class> getSuperclassesAndInterfaces(Class type) {
List<Class> superclasses = []
superclasses.addAll(ClassUtils.getAllSuperclasses(ClassUtils.primitiveToWrapper(type)))
for (Object it in ClassUtils.getAllInterfaces(type)) {
Class interfaceCls = (Class) it
String name = interfaceCls.name
if (name.indexOf('$') == -1) {
if (interfaceCls.package != GormEntity.package) {
superclasses.add(interfaceCls)
}
}
}
superclasses.removeAll([Object, GroovyObject, Serializable, Cloneable, Comparable, WebDataBinding, DirtyCheckable, Entity])
return superclasses.unique()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.springframework.validation.FieldError

import static grails.plugin.formfields.BeanPropertyAccessorFactory.stripIndex
import static java.util.Collections.EMPTY_LIST
import static org.apache.commons.lang.StringUtils.substringAfterLast
import static grails.util.GrailsStringUtils.substringAfterLast

@CompileStatic
@Canonical
Expand Down
Loading