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

se.l4.vibe.mapping.KeyValueToString Maven / Gradle / Ivy

There is a newer version: 0.4.0
Show newest version
package se.l4.vibe.mapping;

/**
 * Utility for creating a {@link #toString()} for something that is a
 * {@link KeyValueMappable}.
 * 
 * @author Andreas Holstenson
 *
 */
public class KeyValueToString
{
	private KeyValueToString()
	{
	}
	
	public static String toString(KeyValueMappable instance)
	{
		StringBuilder builder = new StringBuilder();
		builder.append(instance.getClass().getSimpleName());
		builder.append("{ ");
		
		instance.mapToKeyValues((k, v) -> {
			builder.append(k).append('=').append(v).append(' ');
		});
		
		builder.append('}');
		return builder.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy