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

ch.lambdaj.function.convert.PropertyExtractor Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
// Modified or written by Ex Machina SAGL for inclusion with lambdaj.
// Copyright (c) 2009 Mario Fusco.
// Licensed under the Apache License, Version 2.0 (the "License")

package ch.lambdaj.function.convert;

import ch.lambdaj.util.IntrospectionUtil;


/**
 * Converts an Object in the value it has on the name property.
 * @author Mario Fusco
 */
public class PropertyExtractor implements Converter {

	private final String propertyName;
	
    /**
     * Creates a PropertyExtractor
     */
	public PropertyExtractor(String propertyName) {
		this.propertyName = propertyName; 
	}
	
    /**
     * {@inheritDoc}
     */
	@SuppressWarnings("unchecked")
	public T convert(F from) {
		return (T)IntrospectionUtil.getPropertyValue(from, propertyName);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy