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

uk.co.it.modular.beans.BeanVisitors Maven / Gradle / Ivy

Go to download

Utilities for manipulating and inspecting Java classes implementing the Java Beans standard

There is a newer version: 0.9.10
Show newest version

package uk.co.it.modular.beans;

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;

/**
 * Static repository of {@link BeanVisitor} implementations
 * 
 * @author Stewart Bissett
 */
public abstract class BeanVisitors {

	/**
	 * Print all the properties visited to {@link System#out}
	 */
	public static BeanVisitor print() {
		return print(new OutputStreamWriter(System.out));
	}

	/**
	 * Print all the properties visited to the {@link Writer}
	 */
	public static BeanVisitor print(final Writer writer) {
		return new BeanVisitor() {

			final PrintWriter printer = new PrintWriter(writer);

			public void visit(final BeanPropertyInstance property, final Object current, final String path, final Object[] stack) {
				printer.println("'" + path + "' = '" + property.getValue() + "'");
				printer.flush();
			}
		};
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy