<commit_before>/*
 * Copyright (C) 2004-2007  exedio GmbH (www.exedio.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package com.exedio.cope.pattern;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;

import com.exedio.cope.BooleanField;
import com.exedio.cope.Cope;
import com.exedio.cope.DateField;
import com.exedio.cope.Item;
import com.exedio.cope.ItemField;
import com.exedio.cope.Pattern;
import com.exedio.cope.SetValue;
import com.exedio.cope.StringField;
import com.exedio.cope.Type;
import com.exedio.cope.UniqueConstraint;
import com.exedio.cope.Wrapper;
import com.exedio.cope.util.ReactivationConstructorDummy;

/**
 * This pattern is still experimental, and its API may change any time.
 */
public final class History extends Pattern
{
	ItemField<?> eventParent = null;
	final DateField eventDate = new DateField().toFinal();
	private UniqueConstraint eventUnique = null;
	final StringField eventOrigin = new StringField().toFinal();
	final BooleanField eventCreation = new BooleanField().toFinal();
	Type<Event> eventType = null;
	
	ItemField<Event> featureEvent = null;
	final StringField featureId = new StringField().toFinal();
	private UniqueConstraint featureUnique = null;
	final StringField featureName = new StringField().toFinal();
	final StringField featureOld = new StringField().toFinal().optional();
	final StringField featureNew = new StringField().toFinal().optional();
	Type<Feature> featureType = null;

	@Override
	public void initialize()
	{
		final Type<?> type = getType();
		
		eventParent = type.newItemField(ItemField.DeletePolicy.CASCADE).toFinal();
		eventUnique = new UniqueConstraint(eventParent, eventDate);
		final LinkedHashMap<String, com.exedio.cope.Feature> features = new LinkedHashMap<String, com.exedio.cope.Feature>();
		features.put("parent", eventParent);
		features.put("date", eventDate);
		features.put("uniqueConstraint", eventUnique);
		features.put("origin", eventOrigin);
		features.put("creation", eventCreation);
		eventType = newType(Event.class, features, "Event");
		
		features.clear();
		featureEvent = eventType.newItemField(ItemField.DeletePolicy.CASCADE).toFinal();
		featureUnique = new UniqueConstraint(featureEvent, featureId);
		features.put("event", featureEvent);
		features.put("id", featureId);
		features.put("uniqueConstraint", featureUnique);
		features.put("name", featureName);
		features.put("old", featureOld);
		features.put("new", featureNew);
		featureType = newType(Feature.class, features, "Feature");
	}
	
	public <P extends Item> ItemField<P> getEventParent(final Class<P> parentClass)
	{
		assert eventParent!=null;
		return eventParent.as(parentClass);
	}
	
	public DateField getEventDate()
	{
		return eventDate;
	}
	
	public UniqueConstraint getEventUniqueConstraint()
	{
		assert eventUnique!=null;
		return eventUnique;
	}
	
	public StringField getEventOrigin()
	{
		return eventOrigin;
	}
	
	public BooleanField getEventCreation()
	{
		return eventCreation;
	}
	
	public Type<? extends Item> getEventType()
	{
		assert eventType!=null;
		return eventType;
	}
	
	public ItemField<?> getFeatureEvent()
	{
		assert featureEvent!=null;
		return featureEvent;
	}
	
	public StringField getFeatureId()
	{
		return featureId;
	}
	
	public UniqueConstraint getFeatureUniqueConstraint()
	{
		assert featureUnique!=null;
		return featureUnique;
	}
	
	public StringField getFeatureName()
	{
		return featureName;
	}
	
	public StringField getFeatureOld()
	{
		return featureOld;
	}
	
	public StringField getFeatureNew()
	{
		return featureNew;
	}
	
	public Type<? extends Item> getFeatureType()
	{
		assert featureType!=null;
		return featureType;
	}
	<commit_msg>type more strictly<commit_after>/*
 * Copyright (C) 2004-2007  exedio GmbH (www.exedio.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package com.exedio.cope.pattern;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;

import com.exedio.cope.BooleanField;
import com.exedio.cope.Cope;
import com.exedio.cope.DateField;
import com.exedio.cope.Item;
import com.exedio.cope.ItemField;
import com.exedio.cope.Pattern;
import com.exedio.cope.SetValue;
import com.exedio.cope.StringField;
import com.exedio.cope.Type;
import com.exedio.cope.UniqueConstraint;
import com.exedio.cope.Wrapper;
import com.exedio.cope.util.ReactivationConstructorDummy;

/**
 * This pattern is still experimental, and its API may change any time.
 */
public final class History extends Pattern
{
	ItemField<?> eventParent = null;
	final DateField eventDate = new DateField().toFinal();
	private UniqueConstraint eventUnique = null;
	final StringField eventOrigin = new StringField().toFinal();
	final BooleanField eventCreation = new BooleanField().toFinal();
	Type<Event> eventType = null;
	
	ItemField<Event> featureEvent = null;
	final StringField featureId = new StringField().toFinal();
	private UniqueConstraint featureUnique = null;
	final StringField featureName = new StringField().toFinal();
	final StringField featureOld = new StringField().toFinal().optional();
	final StringField featureNew = new StringField().toFinal().optional();
	Type<Feature> featureType = null;

	@Override
	public void initialize()
	{
		final Type<?> type = getType();
		
		eventParent = type.newItemField(ItemField.DeletePolicy.CASCADE).toFinal();
		eventUnique = new UniqueConstraint(eventParent, eventDate);
		final LinkedHashMap<String, com.exedio.cope.Feature> features = new LinkedHashMap<String, com.exedio.cope.Feature>();
		features.put("parent", eventParent);
		features.put("date", eventDate);
		features.put("uniqueConstraint", eventUnique);
		features.put("origin", eventOrigin);
		features.put("creation", eventCreation);
		eventType = newType(Event.class, features, "Event");
		
		features.clear();
		featureEvent = eventType.newItemField(ItemField.DeletePolicy.CASCADE).toFinal();
		featureUnique = new UniqueConstraint(featureEvent, featureId);
		features.put("event", featureEvent);
		features.put("id", featureId);
		features.put("uniqueConstraint", featureUnique);
		features.put("name", featureName);
		features.put("old", featureOld);
		features.put("new", featureNew);
		featureType = newType(Feature.class, features, "Feature");
	}
	
	public <P extends Item> ItemField<P> getEventParent(final Class<P> parentClass)
	{
		assert eventParent!=null;
		return eventParent.as(parentClass);
	}
	
	public DateField getEventDate()
	{
		return eventDate;
	}
	
	public UniqueConstraint getEventUniqueConstraint()
	{
		assert eventUnique!=null;
		return eventUnique;
	}
	
	public StringField getEventOrigin()
	{
		return eventOrigin;
	}
	
	public BooleanField getEventCreation()
	{
		return eventCreation;
	}
	
	public Type<Event> getEventType()
	{
		assert eventType!=null;
		return eventType;
	}
	
	public ItemField<?> getFeatureEvent()
	{
		assert featureEvent!=null;
		return featureEvent;
	}
	
	public StringField getFeatureId()
	{
		return featureId;
	}
	
	public UniqueConstraint getFeatureUniqueConstraint()
	{
		assert featureUnique!=null;
		return featureUnique;
	}
	
	public StringField getFeatureName()
	{
		return featureName;
	}
	
	public StringField getFeatureOld()
	{
		return featureOld;
	}
	
	public StringField getFeatureNew()
	{
		return featureNew;
	}
	
	public Type<Feature> getFeatureType()
	{
		assert featureType!=null;
		return featureType;
	}
	
{'fraction_non_alphanumeric': 0.10368533754085428, 'fraction_numerical': 0.005409669784740223, 'mean_word_length': 4.967720242098184, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2556558', 'n_tokens_mistral': 2767, 'n_tokens_neox': 2599, 'n_words': 750}