<commit_before>package ch.liquidmind.inflection.print;

import java.io.PrintStream;
import java.io.Writer;
import java.util.Set;

import ch.liquidmind.inflection.association.Association;
import ch.liquidmind.inflection.association.Class;
import ch.liquidmind.inflection.association.Property;

public class AssociationPrinter extends AbstractPrinter
{
	public AssociationPrinter()
	{
		super( DEFAULT_PRINT_STREAM );
	}

	public AssociationPrinter( PrintStream printStream )
	{
		super( printStream );
	}

	public AssociationPrinter( Writer writer )
	{
		super( writer );
	}

	public void printClasses( Set< Class > classes )
	{
		classes.stream().sorted( ( classA, classB ) -> classA.getName().compareToIgnoreCase( classB.getName() ) ).forEach( aClass -> printClass( aClass ) );
	}

	public void printClass( Class aClass )
	{
		getPrintWriter().println( String.format( "Class %s:", getTypeName( aClass.getName() ) ) );
		getPrintWriter().increaseIndent();
		aClass.getOwnedProperties().stream().forEach( property -> printProperty( property ) );
		aClass.getOwnedAssociations().stream().forEach( association -> printAssociation( association ) );
		getPrintWriter().decreaseIndent();
		getPrintWriter().flush();
	}
	
	private void printProperty( Property property )
	{
		Property redefinedProperty = property.getRedefinedProperty();
		Property subsettedProperty = property.getSubsettedProperty();
		String redefinedPropertyName = ( redefinedProperty == null ? "NA" : getTypeName( redefinedProperty.getOwningClass().getName() ) + "." + redefinedProperty.getName() );
		String subsettedPropertyName = ( subsettedProperty == null ? "NA" : getTypeName( subsettedProperty.getOwningClass().getName() ) + "." + subsettedProperty.getName() );
		
		getPrintWriter().println( String.format( "Property %s: Related Type=%s, Aggregation=%s, Redefines=%s, Subsets=%s, Declared=%s, Derived=%s, Derived Union=%s",
			property.getName(), getTypeName( property.getRelatedType().getTypeName() ), property.getAggregation(), 
			redefinedPropertyName, subsettedPropertyName, property.isDeclared(), property.isDerived(), property.isDerivedUnion() ) );
	}

	private void printAssociation( Association association )
	{
		String displayName = ( association.getName().isEmpty() ? "NA" : association.getName() );
		
		getPrintWriter().print( String.format( "Association %s:", displayName ) );
		printPropertyReference( "Self End", association.getSelfEnd() );
		printPropertyReference( "Other End", association.getOtherEnd() );
		getPrintWriter().println( String.format( " Declared=%s", association.isDeclared() ) );
	}

	private void printPropertyReference( String title, Property property )
	{
		getPrintWriter().increaseIndent();
		getPrintWriter().print( " " + title + "=");
		printPropertyReference( property );
		getPrintWriter().decreaseIndent();
	}
	<commit_msg>Added dashes to multi-word display names.<commit_after>package ch.liquidmind.inflection.print;

import java.io.PrintStream;
import java.io.Writer;
import java.util.Set;

import ch.liquidmind.inflection.association.Association;
import ch.liquidmind.inflection.association.Class;
import ch.liquidmind.inflection.association.Property;

public class AssociationPrinter extends AbstractPrinter
{
	public AssociationPrinter()
	{
		super( DEFAULT_PRINT_STREAM );
	}

	public AssociationPrinter( PrintStream printStream )
	{
		super( printStream );
	}

	public AssociationPrinter( Writer writer )
	{
		super( writer );
	}

	public void printClasses( Set< Class > classes )
	{
		classes.stream().sorted( ( classA, classB ) -> classA.getName().compareToIgnoreCase( classB.getName() ) ).forEach( aClass -> printClass( aClass ) );
	}

	public void printClass( Class aClass )
	{
		getPrintWriter().println( String.format( "Class %s:", getTypeName( aClass.getName() ) ) );
		getPrintWriter().increaseIndent();
		aClass.getOwnedProperties().stream().forEach( property -> printProperty( property ) );
		aClass.getOwnedAssociations().stream().forEach( association -> printAssociation( association ) );
		getPrintWriter().decreaseIndent();
		getPrintWriter().flush();
	}
	
	private void printProperty( Property property )
	{
		Property redefinedProperty = property.getRedefinedProperty();
		Property subsettedProperty = property.getSubsettedProperty();
		String redefinedPropertyName = ( redefinedProperty == null ? "NA" : getTypeName( redefinedProperty.getOwningClass().getName() ) + "." + redefinedProperty.getName() );
		String subsettedPropertyName = ( subsettedProperty == null ? "NA" : getTypeName( subsettedProperty.getOwningClass().getName() ) + "." + subsettedProperty.getName() );
		
		getPrintWriter().println( String.format( "Property %s: Related-Type=%s, Aggregation=%s, Redefines=%s, Subsets=%s, Declared=%s, Derived=%s, Derived-Union=%s",
			property.getName(), getTypeName( property.getRelatedType().getTypeName() ), property.getAggregation(), 
			redefinedPropertyName, subsettedPropertyName, property.isDeclared(), property.isDerived(), property.isDerivedUnion() ) );
	}

	private void printAssociation( Association association )
	{
		String displayName = ( association.getName().isEmpty() ? "NA" : association.getName() );
		
		getPrintWriter().print( String.format( "Association %s:", displayName ) );
		printPropertyReference( "Self End", association.getSelfEnd() );
		printPropertyReference( "Other End", association.getOtherEnd() );
		getPrintWriter().println( String.format( " Declared=%s", association.isDeclared() ) );
	}

	private void printPropertyReference( String title, Property property )
	{
		getPrintWriter().increaseIndent();
		getPrintWriter().print( " " + title + "=");
		printPropertyReference( property );
		getPrintWriter().decreaseIndent();
	}
	
{'fraction_non_alphanumeric': 0.13700070077084794, 'fraction_numerical': 0.0, 'mean_word_length': 5.732311320754717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6346818', 'n_tokens_mistral': 1729, 'n_tokens_neox': 1603, 'n_words': 325}