// Path: src/com/concentricsky/android/khanacademy/data/remote/BaseEntityUpdateVisitor.java
// public abstract class BaseEntityUpdateVisitor<T extends EntityBase> implements EntityVisitor {
// 	private T updateFrom;
// 	public BaseEntityUpdateVisitor(T updateFrom) {
// 		this.updateFrom = updateFrom;
// 	}
// 	@Override
// 	public void visit(Topic topic) {
// 		baseUpdate(topic);
// 	}
// 	@Override
// 	public void visit(Video video) {
// 		baseUpdate(video);
// 	}
// 	@Override
// 	public void visit(EntityBase.Impl entity) {
// 		baseUpdate(entity);
// 	}
// 	private void baseUpdate(EntityBase toUpdate) {
// 		String value = updateFrom.getTitle();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setTitle(value);
// 		}
// 		
// 		value = updateFrom.getDescription();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setDescription(value);
// 		}
// 		
// 		value = updateFrom.getHide();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setHide(value);
// 		}
// 		
// 		value = updateFrom.getKa_url();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setKa_url(value);
// 		}
// 		
// 		Topic parent = updateFrom.getParentTopic();
// 		if (!isDefaultValue(parent, Topic.class)) {
// 			toUpdate.setParentTopic(parent);
// 		}
// 		
// 	}
// 	
// 	/**
// 	 * Test a value to see if it is the default value for its type.
// 	 * 
// 	 * @param value The value to check.
// 	 * @param valueType The value's class. In case of primitives, pass the wrapper class, such as Integer.
// 	 * @return true if the value is default for fields of the given type on this class, false otherwise.
// 	 */
// 	protected boolean isDefaultValue(Object value, Class<?> valueType) {
// 		
// 		if (String.class.equals(valueType)) {
// 			return null == value || "".equals(value);
// 		} else if (Integer.class.equals(valueType)) {
// 			return Integer.valueOf(0).equals(value);
// 		} else if (Topic.class.equals(valueType)) {
// 			return null == value;
// 		}
// 		
// 		throw new UnsupportedOperationException(String.format("Unknown type: %s", valueType.getSimpleName()));
// 	}
// 	
// }
// 
// Path: src/com/concentricsky/android/khanacademy/data/remote/EntityVisitor.java
// public interface EntityVisitor {
// 	public void visit(Topic topic);
// 	public void visit(Video video);
// 	public void visit(EntityBase.Impl entity);
// }


import com.concentricsky.android.khanacademy.data.remote.BaseEntityUpdateVisitor;
import com.concentricsky.android.khanacademy.data.remote.EntityVisitor;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.j256.ormlite.field.DatabaseField;
/*
 	Viewer for Khan Academy
    Copyright (C) 2012 Concentric Sky, Inc.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.concentricsky.android.khanacademy.data.db;


@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeInfo(  
    use = JsonTypeInfo.Id.NAME,  
    include = JsonTypeInfo.As.PROPERTY,  
    property = "kind",
    visible = true,
    defaultImpl = EntityBase.Impl.class
    )
@JsonSubTypes({
    @Type(value = Video.class, name = "Video"),  
    @Type(value = Topic.class, name = "Topic")
    })  
public abstract class EntityBase extends ModelBase {
	
	public static class Impl extends EntityBase {
		
		@Override public int getDownloaded_video_count() { return 0; }
		@Override public int getVideo_count() { return 0; } 
		
		@Override
		public String getId() {
			throw new UnsupportedOperationException("But Videos and Topics have ids...");
		}
		
		@Override
		public BaseEntityUpdateVisitor<Impl> buildUpdateVisitor() {
			return new BaseEntityUpdateVisitor<Impl>(this) { };
		}
		
		@Override
// Path: src/com/concentricsky/android/khanacademy/data/remote/BaseEntityUpdateVisitor.java
// public abstract class BaseEntityUpdateVisitor<T extends EntityBase> implements EntityVisitor {
// 	private T updateFrom;
// 	public BaseEntityUpdateVisitor(T updateFrom) {
// 		this.updateFrom = updateFrom;
// 	}
// 	@Override
// 	public void visit(Topic topic) {
// 		baseUpdate(topic);
// 	}
// 	@Override
// 	public void visit(Video video) {
// 		baseUpdate(video);
// 	}
// 	@Override
// 	public void visit(EntityBase.Impl entity) {
// 		baseUpdate(entity);
// 	}
// 	private void baseUpdate(EntityBase toUpdate) {
// 		String value = updateFrom.getTitle();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setTitle(value);
// 		}
// 		
// 		value = updateFrom.getDescription();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setDescription(value);
// 		}
// 		
// 		value = updateFrom.getHide();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setHide(value);
// 		}
// 		
// 		value = updateFrom.getKa_url();
// 		if (!isDefaultValue(value, String.class)) {
// 			toUpdate.setKa_url(value);
// 		}
// 		
// 		Topic parent = updateFrom.getParentTopic();
// 		if (!isDefaultValue(parent, Topic.class)) {
// 			toUpdate.setParentTopic(parent);
// 		}
// 		
// 	}
// 	
// 	/**
// 	 * Test a value to see if it is the default value for its type.
// 	 * 
// 	 * @param value The value to check.
// 	 * @param valueType The value's class. In case of primitives, pass the wrapper class, such as Integer.
// 	 * @return true if the value is default for fields of the given type on this class, false otherwise.
// 	 */
// 	protected boolean isDefaultValue(Object value, Class<?> valueType) {
// 		
// 		if (String.class.equals(valueType)) {
// 			return null == value || "".equals(value);
// 		} else if (Integer.class.equals(valueType)) {
// 			return Integer.valueOf(0).equals(value);
// 		} else if (Topic.class.equals(valueType)) {
// 			return null == value;
// 		}
// 		
// 		throw new UnsupportedOperationException(String.format("Unknown type: %s", valueType.getSimpleName()));
// 	}
// 	
// }
// 
// Path: src/com/concentricsky/android/khanacademy/data/remote/EntityVisitor.java
// public interface EntityVisitor {
// 	public void visit(Topic topic);
// 	public void visit(Video video);
// 	public void visit(EntityBase.Impl entity);
// }


// Path: src/com/concentricsky/android/khanacademy/data/db/EntityBase.java
import com.concentricsky.android.khanacademy.data.remote.BaseEntityUpdateVisitor;
import com.concentricsky.android.khanacademy.data.remote.EntityVisitor;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.j256.ormlite.field.DatabaseField;

/*
 	Viewer for Khan Academy
    Copyright (C) 2012 Concentric Sky, Inc.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.concentricsky.android.khanacademy.data.db;


@JsonIgnoreProperties(ignoreUnknown=true)
@JsonTypeInfo(  
    use = JsonTypeInfo.Id.NAME,  
    include = JsonTypeInfo.As.PROPERTY,  
    property = "kind",
    visible = true,
    defaultImpl = EntityBase.Impl.class
    )
@JsonSubTypes({
    @Type(value = Video.class, name = "Video"),  
    @Type(value = Topic.class, name = "Topic")
    })  
public abstract class EntityBase extends ModelBase {
	
	public static class Impl extends EntityBase {
		
		@Override public int getDownloaded_video_count() { return 0; }
		@Override public int getVideo_count() { return 0; } 
		
		@Override
		public String getId() {
			throw new UnsupportedOperationException("But Videos and Topics have ids...");
		}
		
		@Override
		public BaseEntityUpdateVisitor<Impl> buildUpdateVisitor() {
			return new BaseEntityUpdateVisitor<Impl>(this) { };
		}
		
		@Override
		public void accept(EntityVisitor visitor) {