<commit_before>/*  Copyright 2008 <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.qi4j.entity.ibatis.internal.property;

import org.qi4j.entity.ibatis.internal.IBatisMutableField;
import org.qi4j.property.PropertyInfo;
import org.qi4j.spi.property.PropertyInstance;

/**
 * {@code MutablePropertyInstance} represents a mutable property.
 *
 * @author <EMAIL>
 * @since 0.1.0
 */
public final class MutablePropertyInstance<T> extends PropertyInstance<T>
    implements IBatisMutableField<T>
{
    private boolean isDirty;

    /**
     * Construct an instance of {@code MutableProperty}.
     *
     * @param aPropertyInfo  The property info. This argument must not be {@code null}.
     * @param anInitialValue The initial value. This argument must not be {@code null}.
     * @throws IllegalArgumentException Thrown if the specified {@code aPropertyInfo} argument is {@code null}.
     * @since 0.1.0
     */
    public MutablePropertyInstance( PropertyInfo aPropertyInfo, T anInitialValue )
        throws IllegalArgumentException
    {
        super( aPropertyInfo, anInitialValue );
        isDirty = false;
    }

    public void set( T aNewValue )
    {
        if( !isDirty )
        {
            isDirty = isNotEquals( value, aNewValue );
        }

        super.set( aNewValue );
    }

    /**
     * Returns {@code true} if both arguments are equals.
     *
     * @param aValue       A value.
     * @param anotherValue Another value.
     * @return A {@code boolean} indicator whether both arguments are equal.
     * @since 0.1.0
     */
    static boolean isNotEquals( Object aValue, Object anotherValue )
    {
        if( aValue == anotherValue )
        {<commit_msg>Change Property.set to return T Change all metadata infos to be of type Serializable Expose identity() property in ServiceReference<commit_after>/*  Copyright 2008 <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.qi4j.entity.ibatis.internal.property;

import org.qi4j.entity.ibatis.internal.IBatisMutableField;
import org.qi4j.property.PropertyInfo;
import org.qi4j.spi.property.PropertyInstance;

/**
 * {@code MutablePropertyInstance} represents a mutable property.
 *
 * @author <EMAIL>
 * @since 0.1.0
 */
public final class MutablePropertyInstance<T> extends PropertyInstance<T>
    implements IBatisMutableField<T>
{
    private boolean isDirty;

    /**
     * Construct an instance of {@code MutableProperty}.
     *
     * @param aPropertyInfo  The property info. This argument must not be {@code null}.
     * @param anInitialValue The initial value. This argument must not be {@code null}.
     * @throws IllegalArgumentException Thrown if the specified {@code aPropertyInfo} argument is {@code null}.
     * @since 0.1.0
     */
    public MutablePropertyInstance( PropertyInfo aPropertyInfo, T anInitialValue )
        throws IllegalArgumentException
    {
        super( aPropertyInfo, anInitialValue );
        isDirty = false;
    }

    public T set( T aNewValue )
    {
        if( !isDirty )
        {
            isDirty = isNotEquals( value, aNewValue );
        }

        super.set( aNewValue );

        return aNewValue;
    }

    /**
     * Returns {@code true} if both arguments are equals.
     *
     * @param aValue       A value.
     * @param anotherValue Another value.
     * @return A {@code boolean} indicator whether both arguments are equal.
     * @since 0.1.0
     */
    static boolean isNotEquals( Object aValue, Object anotherValue )
    {
        if( aValue == anotherValue )
        {
{'fraction_non_alphanumeric': 0.08761987794245858, 'fraction_numerical': 0.009154315605928508, 'mean_word_length': 2.9390557939914164, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2282844', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1248, 'n_words': 458}