import java.io.Serializable;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Unique;

/**
 * TODO: reflect on getters / setters, as mentioned here
 * 
 * @see http://stackoverflow.com
 *      /questions/996179/allen-holub-wrote-you-should-never-use
 *      -get-set-functions-is-he-correct
 */
@PersistenceCapable(detachable = "true", identityType = IdentityType.APPLICATION)
@Inheritance(customStrategy = "complete-table")
@SuppressWarnings("serial")
public class Player implements Serializable {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
    private String id;

    @Persistent
    @Unique
    private String name;

    public String getId() {
        return this.id;
    }

    @Persistent
    private String md5pwd;

    @Persistent(defaultFetchGroup = "true", dependent = "true")
    private Ranking ranking;

    public Player() {
    }

    public Ranking getRanking() {
        return this.ranking;
    }

    public Player(final String name) {
        this.name = name;
    }

    public void setRanking(final Ranking ranking) {
        this.ranking = ranking;
    }
}
