All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zys.mybatis.annotation.validate.NotDistinctListClass Maven / Gradle / Ivy

There is a newer version: 0.2.7
Show newest version
package com.zys.mybatis.annotation.validate;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.List;

/**
 * @author zys
 * @version 1.0
 * @date 2021/1/28 18:00
 */
public class NotDistinctListClass implements ConstraintValidator {

   public void initialize(NotDistinctList constraint) {

   }

   public boolean isValid(Object obj, ConstraintValidatorContext context) {
      if (obj instanceof List) {
         List list = (List)obj;
         long count = list.stream().distinct().count();
         if (list.size() == count) {
            return true;
         }
         return false;
      }
      return true;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy