001package ball.util.ant.taskdefs; 002/*- 003 * ########################################################################## 004 * Utilities 005 * $Id: AntTaskAttributeConstraint.java 5285 2020-02-05 04:23:21Z ball $ 006 * $HeadURL: svn+ssh://svn.hcf.dev/var/spool/scm/repository.svn/ball-util/trunk/src/main/java/ball/util/ant/taskdefs/AntTaskAttributeConstraint.java $ 007 * %% 008 * Copyright (C) 2008 - 2020 Allen D. Ball 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * ########################################################################## 022 */ 023import java.lang.annotation.Documented; 024import java.lang.annotation.Retention; 025import java.lang.annotation.Target; 026import lombok.NoArgsConstructor; 027import org.apache.tools.ant.Task; 028import org.apache.tools.ant.TaskConfigurationChecker; 029 030import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 031import static java.lang.annotation.ElementType.FIELD; 032import static java.lang.annotation.ElementType.METHOD; 033import static java.lang.annotation.RetentionPolicy.RUNTIME; 034import static lombok.AccessLevel.PROTECTED; 035 036/** 037 * JSR303-inspired Ant Task attribute constraint annotation. 038 * 039 * @author {@link.uri mailto:ball@hcf.dev Allen D. Ball} 040 * @version $Revision: 5285 $ 041 */ 042@Documented 043@Retention(RUNTIME) 044@Target({ ANNOTATION_TYPE, FIELD, METHOD }) 045public @interface AntTaskAttributeConstraint { 046 Class<? extends AntTaskAttributeConstraint.Checker> value(); 047 048 /** 049 * {@link #value()} base class 050 */ 051 @NoArgsConstructor(access = PROTECTED) 052 public static abstract class Checker { 053 054 /** 055 * Method to validate an attribute value. 056 * 057 * @param task The {@link Task} that owns and is validating 058 * the attribute. 059 * @param checker The {@link TaskConfigurationChecker} to 060 * report violations. 061 * @param name The name of the attribute. 062 * @param value The attribute value. 063 */ 064 protected abstract void check(Task task, 065 TaskConfigurationChecker checker, 066 String name, Object value); 067 } 068}