Package com.sk89q.intake.parametric.binding

Examples of com.sk89q.intake.parametric.binding.BindingBehavior


     * Validate this parameter and its binding.
     */
    void validate(Method method, int parameterIndex) throws ParametricException {
        // We can't have indeterminate consumers without @Switches otherwise
        // it may screw up parameter processing for later bindings
        BindingBehavior behavior = getBinding().getBehavior(this);
        boolean indeterminate = (behavior == BindingBehavior.INDETERMINATE);
        if (!isValueFlag() && indeterminate) {
            throw new ParametricException(
                    "@Switch missing for indeterminate consumer\n\n" +
                    "Notably:\nFor the type " + type + ", the binding " +
                    getBinding().getClass().getCanonicalName() +
                    "\nmay or may not consume parameters (isIndeterminateConsumer(" + type + ") = true)" +
                    "\nand therefore @Switch(flag) is required for parameter #" + parameterIndex + " of \n" +
                    method.toGenericString());
        }
       
        // getConsumedCount() better return -1 if the BindingBehavior is not CONSUMES
        if (behavior != BindingBehavior.CONSUMES && binding.getConsumedCount(this) != -1) {
            throw new ParametricException(
                    "getConsumedCount() does not return -1 for binding " +
                    getBinding().getClass().getCanonicalName() +
                    "\neven though its behavior type is " + behavior.name() +
                    "\nfor parameter #" + parameterIndex + " of \n" +
                    method.toGenericString());
        }
       
        // getConsumedCount() should not return 0 if the BindingBehavior is not PROVIDES
        if (behavior != BindingBehavior.PROVIDES && binding.getConsumedCount(this) == 0) {
            throw new ParametricException(
                    "getConsumedCount() must not return 0 for binding " +
                    getBinding().getClass().getCanonicalName() +
                    "\nwhen its behavior type is " + behavior.name() + " and not PROVIDES " +
                    "\nfor parameter #" + parameterIndex + " of \n" +
                    method.toGenericString());
        }
    }
View Full Code Here

TOP

Related Classes of com.sk89q.intake.parametric.binding.BindingBehavior

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.