package com.google.step.coffee.data;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.PreparedQuery;
import com.google.appengine.api.datastore.Query;
import java.util.ArrayList;
import java.util.List;

public class TagStore {
  private static TagStore instance = new TagStore();

  private DatastoreService datastore;

  private TagStore() {
    datastore = DatastoreServiceFactory.getDatastoreService();
  }

  public static TagStore getInstance() {
    return instance;
  }

  public List<String> getTags() {
    Query query = new Query("Tag");
    PreparedQuery results = datastore.prepare(query);

    List<String> tags = new ArrayList<>();

    for (Entity entity : results.asIterable()) {
      tags.add((String) entity.getProperty("name"));
    }

    return tags;
  }

  public void addTags(List<String> tags) {
    for (String tag : tags) {
      Key tagKey = KeyFactory.createKey("Tag", tag);
      Entity tagEntity = new Entity(tagKey);
      tagEntity.setProperty("name", tag);

      datastore.put(tagEntity);
    }
  }
}

@@ -467,16 +467,106 @@
 .List;%0A%0A
+/**%0A * Representation for the storage method for tags. Uses singleton design pattern.%0A */%0A
 public c
@@ -828,24 +828,86 @@
 tance;%0A  %7D%0A%0A
+  /**%0A   * Returns a List of all currently stored tags.%0A   */%0A
   public Lis
@@ -1190,24 +1190,164 @@
  tags;%0A  %7D%0A%0A
+  /**%0A   * Adds given tags to the store, not creating duplicates.%0A   * @param tags List of tags used to be added to the store if new.%0A   */%0A
   public voi

Add comments for clarity in TagStore