grails.plugin.json.view.api.internal.DefaultJsonViewIncludeExcludeSupport.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of views-json Show documentation
Show all versions of views-json Show documentation
Provides additional view technologies to the Grails framework, including JSON and Markup views.
The newest version!
package grails.plugin.json.view.api.internal
import groovy.transform.CompileStatic
import org.grails.core.util.IncludeExcludeSupport
@CompileStatic
class DefaultJsonViewIncludeExcludeSupport extends IncludeExcludeSupport {
DefaultJsonViewIncludeExcludeSupport(List defaultIncludes, List defaultExcludes) {
super(defaultIncludes, defaultExcludes)
}
@Override
boolean shouldInclude(List incs, List excs, String object) {
def i = object.lastIndexOf('.')
String unqualified = i > -1 ? object.substring(i + 1) : null
return super.shouldInclude(incs, excs, object) && (unqualified == null || (includes(defaultIncludes, unqualified) && !excludes(defaultExcludes, unqualified)))
}
@Override
boolean includes(List includes, String object) {
includes == null ||
includes.contains(object) ||
includes.any { object.startsWith(it + ".") } ||
includes.any { it.startsWith(object + ".") }
}
}