Example usage for org.apache.commons.collections.functors UniquePredicate UniquePredicate

List of usage examples for org.apache.commons.collections.functors UniquePredicate UniquePredicate

Introduction

In this page you can find the example usage for org.apache.commons.collections.functors UniquePredicate UniquePredicate.

Prototype

public UniquePredicate() 

Source Link

Document

Constructor that performs no validation.

Usage

From source file:net.shopxx.controller.admin.ParameterController.java

@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(Parameter parameter, Long productCategoryId, RedirectAttributes redirectAttributes) {
    CollectionUtils.filter(parameter.getNames(), new AndPredicate(new UniquePredicate(), new Predicate() {
        public boolean evaluate(Object object) {
            String name = (String) object;
            return StringUtils.isNotEmpty(name);
        }/*from w  ww  .jav  a 2  s .  co m*/
    }));
    parameter.setProductCategory(productCategoryService.find(productCategoryId));
    if (!isValid(parameter, BaseEntity.Save.class)) {
        return ERROR_VIEW;
    }
    parameterService.save(parameter);
    addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
    return "redirect:list.jhtml";
}

From source file:net.shopxx.controller.admin.SpecificationController.java

@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(Specification specification, Long productCategoryId, RedirectAttributes redirectAttributes) {
    CollectionUtils.filter(specification.getOptions(), new AndPredicate(new UniquePredicate(), new Predicate() {
        public boolean evaluate(Object object) {
            String option = (String) object;
            return StringUtils.isNotEmpty(option);
        }//from   w w w.j a v a 2 s  . c o m
    }));
    specification.setProductCategory(productCategoryService.find(productCategoryId));
    if (!isValid(specification, BaseEntity.Save.class)) {
        return ERROR_VIEW;
    }
    specificationService.save(specification);
    addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
    return "redirect:list.jhtml";
}

From source file:net.shopxx.controller.admin.ParameterController.java

@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(Parameter parameter, RedirectAttributes redirectAttributes) {
    CollectionUtils.filter(parameter.getNames(), new AndPredicate(new UniquePredicate(), new Predicate() {
        public boolean evaluate(Object object) {
            String name = (String) object;
            return StringUtils.isNotEmpty(name);
        }/* www .j  av a 2 s . c o  m*/
    }));
    if (!isValid(parameter, BaseEntity.Update.class)) {
        return ERROR_VIEW;
    }
    parameterService.update(parameter, "productCategory");
    addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
    return "redirect:list.jhtml";
}

From source file:net.shopxx.controller.admin.SpecificationController.java

@RequestMapping(value = "/update", method = RequestMethod.POST)
public String update(Specification specification, RedirectAttributes redirectAttributes) {
    CollectionUtils.filter(specification.getOptions(), new AndPredicate(new UniquePredicate(), new Predicate() {
        public boolean evaluate(Object object) {
            String option = (String) object;
            return StringUtils.isNotEmpty(option);
        }//from  w w w.  j a v a 2  s . c  om
    }));
    if (!isValid(specification)) {
        return ERROR_VIEW;
    }
    specificationService.update(specification, "productCategory");
    addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
    return "redirect:list.jhtml";
}