Method.groovy
01 /*
02  * SPDX-License-Identifier: Apache-2.0
03  *
04  * Copyright 2019-2021 Andres Almiray.
05  *
06  * Licensed under the Apache License, Version 2.0 (the "License");
07  * you may not use this file except in compliance with the License.
08  * You may obtain a copy of the License at
09  *
10  *     https://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 package org.kordamp.gradle.plugin.yguard.tasks
19 
20 import groovy.transform.CompileStatic
21 import org.gradle.api.Project
22 import org.gradle.api.provider.ListProperty
23 import org.gradle.api.provider.Property
24 
25 import javax.inject.Inject
26 
27 /**
28  *
29  @author Andres Almiray
30  @since 0.1.0
31  */
32 @CompileStatic
33 class Method {
34     final Property<String> name
35     final Property<String> class_
36     final ListProperty<String> includes
37     final ListProperty<String> excludes
38 
39     @Inject
40     Method(Project project) {
41         name = project.objects.property(String)
42         class_ = project.objects.property(String)
43         includes = project.objects.listProperty(String)
44         excludes = project.objects.listProperty(String)
45     }
46 
47     List<String> validate() {
48         List<String> errors = []
49 
50         errors
51     }
52 
53     void include(String s) {
54         includes.add(s)
55     }
56 
57     void exclude(String s) {
58         excludes.add(s)
59     }
60 
61     boolean hasPatternSet() {
62         (includes.present && includes.get().size() 0||
63             (excludes.present && excludes.get().size() 0)
64     }
65 
66     boolean isEmpty() {
67         !name.present &&
68             !class_.present &&
69             !hasPatternSet()
70     }
71 }