Package org.springframework.rules

Examples of org.springframework.rules.Rules


    public void setSettings(DataPoolSettings settings) {
        this.settings = settings;
    }

    public void load() {
        addRules(new Rules(Person.class) {

            @Override
            protected void initRules() {
                add("name", NAME_VALIDATION);
            }
        });

        addRules(new Rules(Location.class) {

            @Override
            protected void initRules() {
                add("capacity", all(new Constraint[]{gte(1), required()}));
                add("name", NAME_VALIDATION);
            }
        });

        addRules(new Rules(Event.class) {

            @Override
            protected void initRules() {
                add("start", all(new Constraint[]{gte(0),
                            lt(settings.getTimeslotsPerWeek()), required()}));
                add("name", NAME_VALIDATION);
            }
        });

        addRules(new Rules(Feature.class) {

            @Override
            protected void initRules() {
                add("name", NAME_VALIDATION);
            }
View Full Code Here


      }
        initRules();
    }

    protected void initRules() {
        this.validationRules = new Rules(getClass()) {
            protected void initRules() {
                add(PROPERTY_USERNAME, all(new Constraint[] { required(), maxLength(getUsernameMaxLength()) }));
                add(PROPERTY_PASSWORD, all(new Constraint[] { required(), minLength(getPasswordMinLength()) }));
            }
View Full Code Here

    /**
     * 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

    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

        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

            }
        };
    }

    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

  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

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

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

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

    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

TOP

Related Classes of org.springframework.rules.Rules

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.