
package org.qi4j.api.entity;

import org.qi4j.api.injection.scope.State;
import org.qi4j.api.mixin.Mixins;
import org.qi4j.api.property.Immutable;
import org.qi4j.api.property.Property;

/**
 * This interface provides the identity of the object which may be used
 * to store the state in a database. It is not the responsibility of the
 * framework to come up with a good identity string.
 */
@Mixins( Identity.IdentityMixin.class )
public interface Identity
{
    /**
     * Returns the client view of the identity.
     * <p/>
     * It is unique within the owning repository, but potentially not unique globally and between
     * types.
     *
     * @return The Identity of 'this' composite.
     */
    @Immutable
    Property<String> identity();

    /**
     * Default Identity implementation.
     */
    public class IdentityMixin
        implements Identity
    {
        @State
        private Property<String> identity;

        @Override
        public Property<String> identity()
        {
            return identity;
        }
    }
}
