Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Collection;

import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;

public class Main {
    public static boolean valueExists(String propertyName, Object value, Collection<?> collection) {

        for (Object o : collection) {
            BeanWrapper bw = new BeanWrapperImpl(o);
            Object propertyValue = bw.getPropertyValue(propertyName);
            if (propertyValue.equals(value)) {
                return true;
            }
        }
        return false;
    }
}