<commit_before>package org.neo4j.api.core;

/**
 * A dynamically instantiated and named {@link RelationshipType}. This class is
 * a convenience implementation of <code>RelationshipType</code> that is
 * typically used when relationship types are created and named after a
 * condition that can only be detected at runtime.
 * <p>
 * If all relationship types are
 * known at compile time, it's better to use the relationship type enum idiom
 * as outlined in {@link RelationshipType}.
 * <p>
 * It's very important to note that a relationship type is uniquely identified
 * by its name, not by any particular instance that implements this interface.
 * This means that the proper way to check if two relationship types are equal
 * is by invoking <code>equals()</code> on their {@link #name names}, NOT by
 * using Java's identity operator (<code>==</code>) or <code>equals()</code>
 * on the relationship type instances. A consequence of this is that you can NOT
 * use relationship types in hashed collections such as {@link java.util.HashMap
 * HashMap} and {@link java.util.HashSet HashSet}. 
 * <p>
 * However, you usually want to check whether a specific relationship
 * <i>instance</i> is of a certain type. That is best achieved with the
 * {@link Relationship#isType Relationship.isType} method, such as: <code><pre>
 * DynamicRelationshipType type = DynamicRelationshipType.withName( "myname" );
 * if ( rel.isType( type ) )
 * {
 *     ...
 * }
 * </pre></code>
 */
public final class DynamicRelationshipType implements RelationshipType
{
    private final String name;
    
    private DynamicRelationshipType( String name )
    {
        if ( name == null )
        {
            throw new IllegalArgumentException( "A relationship type cannot " +
            	"have a null name" );
        }
        this.name = name;
    }

    /**
     * Instantiates a new DynamicRelationshipType with the given name, without
     * creating it in the underlying storage. The relationship type is created
     * only when the first relationship of this type has been commited. 
     * @param name the name of the dynamic relationship type
     * @throws IllegalArgumentException if name is <code>null</code>
     */
    public static DynamicRelationshipType withName( String name )
    {
        return new DynamicRelationshipType( name );
    }

    /**
     * Returns the name of this relationship type. The name uniquely identifies
     * a relationship type, i.e. two different RelationshipType instances
     * with different object identifiers (and possibly even different classes)
     * are semantically equivalent if they have {@link String#equals(Object)<commit_msg>Rephrased a note about when reltypes are actually persistent in underlying storage (changed from "created" to "persisted").<commit_after>package org.neo4j.api.core;

/**
 * A dynamically instantiated and named {@link RelationshipType}. This class is
 * a convenience implementation of <code>RelationshipType</code> that is
 * typically used when relationship types are created and named after a
 * condition that can only be detected at runtime.
 * <p>
 * If all relationship types are
 * known at compile time, it's better to use the relationship type enum idiom
 * as outlined in {@link RelationshipType}.
 * <p>
 * It's very important to note that a relationship type is uniquely identified
 * by its name, not by any particular instance that implements this interface.
 * This means that the proper way to check if two relationship types are equal
 * is by invoking <code>equals()</code> on their {@link #name names}, NOT by
 * using Java's identity operator (<code>==</code>) or <code>equals()</code>
 * on the relationship type instances. A consequence of this is that you can NOT
 * use relationship types in hashed collections such as {@link java.util.HashMap
 * HashMap} and {@link java.util.HashSet HashSet}. 
 * <p>
 * However, you usually want to check whether a specific relationship
 * <i>instance</i> is of a certain type. That is best achieved with the
 * {@link Relationship#isType Relationship.isType} method, such as: <code><pre>
 * DynamicRelationshipType type = DynamicRelationshipType.withName( "myname" );
 * if ( rel.isType( type ) )
 * {
 *     ...
 * }
 * </pre></code>
 */
public final class DynamicRelationshipType implements RelationshipType
{
    private final String name;
    
    private DynamicRelationshipType( String name )
    {
        if ( name == null )
        {
            throw new IllegalArgumentException( "A relationship type cannot " +
            	"have a null name" );
        }
        this.name = name;
    }

    /**
     * Instantiates a new DynamicRelationshipType with the given name, without
     * creating it in the underlying storage. The relationship type is persisted
     * only when the first relationship of this type has been commited. 
     * @param name the name of the dynamic relationship type
     * @throws IllegalArgumentException if name is <code>null</code>
     */
    public static DynamicRelationshipType withName( String name )
    {
        return new DynamicRelationshipType( name );
    }

    /**
     * Returns the name of this relationship type. The name uniquely identifies
     * a relationship type, i.e. two different RelationshipType instances
     * with different object identifiers (and possibly even different classes)
     * are semantically equivalent if they have {@link String#equals(Object)
{'fraction_non_alphanumeric': 0.07958287596048298, 'fraction_numerical': 0.00036589828027808267, 'mean_word_length': 3.451954397394137, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '7147384', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1321, 'n_words': 633}