Intuitive DSL for Java

Version 2.0.0 · src/main/java/ch/dbalabs/intuitivedsl/annotation/Bind.java

Git clone
git clone https://www.dbalabs.ch/git/intuitive-dsl-java.git

Bind.java

/*
 * This file is part of the Intuitive DSL project.
 * Copyright (c) 2026 DBA Labs - Switzerland. All rights reserved.
 *
 * This program is dual-licensed under a commercial license and the AGPLv3.
 * For commercial licensing, contact us at [email protected] or visit https://www.dbalabs.ch.
 *
 * AGPLv3 licensing:
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, version 3 (19 November 2007).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/agpl-3.0.html>.
 */

package ch.dbalabs.intuitivedsl.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Binds a parameter extracted from the user input (via the iBNF grammar)
 * to a field or a method parameter of the target command class.
 * <p>
 * The Intuitive DSL engine will automatically perform type conversion (e.g., from String to Integer)
 * before injecting the value.
 * </p>
 *
 * @author DBA Labs
 */
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Bind {

    /**
     * The name of the parameter as defined in lowercase in the iBNF grammar.
     * * @return the parameter name (e.g., "username", "number_of_days")
     */
    String value();

    /**
     * Used to resolve ambiguities when the same parameter name appears
     * multiple times in the syntax (e.g., "dd.mm.yyyy").
     * <p>
     * Specifies the keyword (context) that precedes this parameter in the specific
     * branch of the grammar you want to target.
     * </p>
     * * @return the preceding keyword, or an empty string if no context is required
     */
    String after() default "";
}