<commit_before>package to.etc.domui.component.meta.impl;

import java.util.*;

import to.etc.domui.component.meta.*;
import to.etc.domui.converter.*;
import to.etc.domui.util.*;

/**
 * This describes a normalized expanded display property. This is the base version
 * used for all single properties. When a property refers to another class which must
 * be rendered as multiple columns then the derived class ExpandedDisplayPropertyList
 * is used.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * Created on Jul 28, 2008
 */
public class ExpandedDisplayProperty implements PropertyMetaModel {
	private ClassMetaModel m_classModel;

	private PropertyMetaModel m_propertyMeta;

	//	private DisplayPropertyMetaModel	m_displayMeta;
	private IValueAccessor< ? > m_accessor;

	private Class< ? > m_actualType;

	private int m_displayLength;

	private Class<? extends IConverter<?>> m_converterClass;

	private SortableType m_sortableType = SortableType.UNKNOWN;

	private String m_propertyName;

	protected ExpandedDisplayProperty(DisplayPropertyMetaModel displayMeta, PropertyMetaModel propertyMeta, IValueAccessor< ? > accessor) {
		//		m_displayMeta = displayMeta;
		m_propertyMeta = propertyMeta;
		m_accessor = accessor;
		if(propertyMeta != null) { // ORDER 1
			m_classModel = m_propertyMeta.getClassModel();
			m_actualType = m_propertyMeta.getActualType();
			m_propertyName = m_propertyMeta.getName();
			m_converterClass = propertyMeta.getConverterClass();
			if(m_sortableType == SortableType.UNKNOWN)
				setSortable(propertyMeta.getSortable());
			if(m_displayLength <= 0) {
				m_displayLength = propertyMeta.getDisplayLength();
				if(m_displayLength <= 0)
					m_displayLength = propertyMeta.getLength();
			}
		}
		if(displayMeta != null) { // ORDER 2 (overrides propertyMeta)
			m_converterClass = displayMeta.getConverterClass();
			setSortable(displayMeta.getSortable());
			m_displayLength = displayMeta.getDisplayLength();
		}
	}

	/**
	 * Get the display expansion for a single property. If the property refers to a compound
	 * this will return an {@link ExpandedDisplayPropertyList}.
	 * @param clz
	 * @param property
	 * @return
	 */
	static public ExpandedDisplayProperty expandProperty(ClassMetaModel cmm, String property) {
		PropertyMetaModel pmm = cmm.findProperty(property); // Get primary metadata
		if(pmm == null)
			throw new IllegalStateException("Unknown property '" + property + "' on classModel=" + cmm);
		return expandProperty(pmm);
	}

	/**
	 * Get the display expansion for a single property. If the property refers to a compound<commit_msg>Bugfix: DisplayMetaData overwrote property metadata even if display metadata was not set, causing the default converters and stuff to be overridden to  null or unset.<commit_after>package to.etc.domui.component.meta.impl;

import java.util.*;

import to.etc.domui.component.meta.*;
import to.etc.domui.converter.*;
import to.etc.domui.util.*;

/**
 * This describes a normalized expanded display property. This is the base version
 * used for all single properties. When a property refers to another class which must
 * be rendered as multiple columns then the derived class ExpandedDisplayPropertyList
 * is used.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * Created on Jul 28, 2008
 */
public class ExpandedDisplayProperty implements PropertyMetaModel {
	private ClassMetaModel m_classModel;

	private PropertyMetaModel m_propertyMeta;

	//	private DisplayPropertyMetaModel	m_displayMeta;
	private IValueAccessor< ? > m_accessor;

	private Class< ? > m_actualType;

	private int m_displayLength;

	private Class<? extends IConverter<?>> m_converterClass;

	private SortableType m_sortableType = SortableType.UNKNOWN;

	private String m_propertyName;

	protected ExpandedDisplayProperty(DisplayPropertyMetaModel displayMeta, PropertyMetaModel propertyMeta, IValueAccessor< ? > accessor) {
		//		m_displayMeta = displayMeta;
		m_propertyMeta = propertyMeta;
		m_accessor = accessor;
		if(propertyMeta != null) { // ORDER 1
			m_classModel = m_propertyMeta.getClassModel();
			m_actualType = m_propertyMeta.getActualType();
			m_propertyName = m_propertyMeta.getName();
			m_converterClass = propertyMeta.getConverterClass();
			if(m_sortableType == SortableType.UNKNOWN)
				setSortable(propertyMeta.getSortable());
			if(m_displayLength <= 0) {
				m_displayLength = propertyMeta.getDisplayLength();
				if(m_displayLength <= 0)
					m_displayLength = propertyMeta.getLength();
			}
		}
		if(displayMeta != null) { // ORDER 2 (overrides propertyMeta)
			if(displayMeta.getConverterClass() != null)
				m_converterClass = displayMeta.getConverterClass();
			if(displayMeta.getSortable() != SortableType.UNKNOWN)
				setSortable(displayMeta.getSortable());
			if(displayMeta.getDisplayLength() > 0)
				m_displayLength = displayMeta.getDisplayLength();
		}
	}

	/**
	 * Get the display expansion for a single property. If the property refers to a compound
	 * this will return an {@link ExpandedDisplayPropertyList}.
	 * @param clz
	 * @param property
	 * @return
	 */
	static public ExpandedDisplayProperty expandProperty(ClassMetaModel cmm, String property) {
		PropertyMetaModel pmm = cmm.findProperty(property); // Get primary metadata
		if(pmm == null)
			throw new IllegalStateException("Unknown property '" + property + "' on classModel=" + cmm);
		return expandProperty(pmm);
	}

	/**
	 * Get the display expansion for a single property. If the property refers to a compound
{'fraction_non_alphanumeric': 0.09386413440467495, 'fraction_numerical': 0.003834915997078159, 'mean_word_length': 4.839019189765459, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 22, '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': '6443046', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1547, 'n_words': 437}