Examples of Rules


Examples of org.springframework.rules.Rules

    /**
     * Initialize the field constraints for our properties. Minimal constraints are
     * enforced here. If you need more control, you should override this in a subtype.
     */
    protected void initRules() {
        this.validationRules = new Rules( getClass() ) {
            protected void initRules() {
                add( PROPERTY_USERNAME, all( new Constraint[] { required(), minLength( getUsernameMinLength() ) } ) );
                add( PROPERTY_PASSWORD, all( new Constraint[] { required(), minLength( getPasswordMinLength() ) } ) );
            }

View Full Code Here

Examples of org.springframework.rules.Rules

    public PropertyConstraint getPropertyConstraint(Class bean, String propertyName, String contextId) {
        if (logger.isDebugEnabled()) {
            logger.debug("Retrieving rules for bean '" + bean + "', context = " + contextId + ", property '"
                    + propertyName + "'");
        }
        Rules rules = getRules(bean, contextId);
        if (rules != null)
            return rules.getPropertyConstraint(propertyName);

        return null;
    }
View Full Code Here

Examples of org.springframework.rules.Rules

        addRules(createOwnerRules());
        addRules(createPetRules());
    }

    private Rules createOwnerRules() {
        return new Rules(Owner.class) {
            protected void initRules() {
                add("firstName", getNameValueConstraint());
                add("lastName", getNameValueConstraint());
                add(not(eqProperty("firstName", "lastName")));
                add("address", required());
View Full Code Here

Examples of org.springframework.rules.Rules

            }
        };
    }

    private Rules createPetRules() {
        return new Rules(Pet.class) {
            protected void initRules() {
                add("type", required());
                add("name", getNameValueConstraint());
                add("birthDate", required());
                add("birthDate", lt(new Date()));
View Full Code Here

Examples of org.springframework.rules.Rules

  private Rules createContactRules() {
    // Construct a Rules object that contains all the constraints we need to apply
    // to our domain object. The Rules class offers a lot of convenience methods
    // for creating constraints on named properties.

    return new Rules(Contact.class) {
      protected void initRules() {
        add("firstName", NAME_CONSTRAINT);
        add("lastName", NAME_CONSTRAINT);
        add(not(eqProperty("firstName", "lastName")));
View Full Code Here

Examples of org.springframework.rules.Rules

        addRules(createSearchRules());
        addRules(createGoogleKeyRules());
  }

  private Rules createGoogleKeyRules(){
    return new Rules(GoogleSettingsBean.class){
      protected void initRules(){
        add("googleKeyTextInput", required());
      }
    };
  }
View Full Code Here

Examples of org.springframework.rules.Rules

      }
    };
  }
 
    private Rules createSearchRules(){
      return new Rules(SearchBean.class) {
            protected void initRules() {
                add("queryString", required());
            }
        };
    }
View Full Code Here

Examples of org.springframework.rules.Rules

    public AttributesRulesSource(Attributes attributes) {
        this.attributes = attributes;
    }

    public synchronized Rules getRules(Class beanClass, String contextId) {
        Rules rules = super.getRules(beanClass, contextId);
        if (rules == null) {
            buildRules(beanClass);
            rules = super.getRules(beanClass, contextId);
        }
        return rules;
View Full Code Here

Examples of org.springframework.rules.Rules

        }
        return rules;
    }

    private void buildRules(Class beanClass) {
        Rules rules = new Rules(beanClass);
        PropertyDescriptor[] propertDescriptors = new BeanWrapperImpl(beanClass).getPropertyDescriptors();
        for (int i = 0; i < propertDescriptors.length; i++) {
            loadPropertyConstraints(rules, propertDescriptors[i]);
        }
        addRules(rules);
View Full Code Here

Examples of org.springframework.rules.Rules

        model.setValidating(true);
    }

    private void setRulesAndHibernateValidator()
    {
        Rules rules = new Rules(ValidatingObject.class);
        Constraints c = Constraints.instance();
        rules.add(c.eq("intValue", 8));
        rules.add(c.eq("stringValue", "valid"));
        DefaultRulesSource source = new DefaultRulesSource();
        source.addRules(rules);
        RulesValidator rulesValidator = new RulesValidator(model, source);
        hibernateRulesValidator = new HibernateRulesValidator(model, ValidatingObject.class);
        CompositeRichValidator compositeValidator = new CompositeRichValidator(rulesValidator, hibernateRulesValidator);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.