// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java
// public interface TableKey {
//     String getRowKey();
//     String getPartitionKey();
//     Class<? extends TableServiceEntity> getEntityClass();
//     AzureTableName getTable();
// }
// 
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java
// public abstract class TableType extends TableServiceEntity {
//     protected final AzureTableName azureTableName;
// 
//     protected TableType(AzureTableName azureTableName) {
//         this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null");
//     }
// 
//     public AzureTableName getAzureTableName() {
//         return azureTableName;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (!(o instanceof TableType)) return false;
// 
//         TableType that = (TableType) o;
// 
//         if (azureTableName != that.azureTableName) return false;
//         if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false;
//         if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = azureTableName.hashCode();
//         result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0);
//         result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0);
//         return result;
//     }
// }


import com.google.common.collect.ImmutableList;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.table.*;
import com.yammer.breakerbox.azure.core.AzureTableName;
import com.yammer.breakerbox.azure.core.TableKey;
import com.yammer.breakerbox.azure.core.TableType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.Response;
import java.net.URISyntaxException;
import java.util.Optional;
import static com.google.common.base.Preconditions.checkNotNull;
    }

    public boolean insert(TableType entity) {
        try {
            return tableRefrence(entity.getAzureTableName())
                    .execute(TableOperation.insert(entity))
                    .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode();
        } catch (StorageException e) {
            LOG.warn("Error performing operation on Storage service", e);
        }
        throw new IllegalStateException("Error adding data in table " + entity.getAzureTableName());
    }

    public boolean insertOrReplace(TableType entity) {
        try {
            final TableResult tableResult = tableRefrence(entity.getAzureTableName())
                    .execute(TableOperation.insertOrReplace(entity));
            switch (Response.Status.fromStatusCode(tableResult.getHttpStatusCode())) {
                case CREATED:
                case NO_CONTENT:
                    return true;
                default:
                    return false;
            }
        } catch (StorageException e) {
            LOG.warn("Error performing operation on Storage service", e);
        }
        throw new IllegalStateException("Error insertOrReplace in table " + entity.getAzureTableName());
    }

// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableKey.java
// public interface TableKey {
//     String getRowKey();
//     String getPartitionKey();
//     Class<? extends TableServiceEntity> getEntityClass();
//     AzureTableName getTable();
// }
// 
// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/core/TableType.java
// public abstract class TableType extends TableServiceEntity {
//     protected final AzureTableName azureTableName;
// 
//     protected TableType(AzureTableName azureTableName) {
//         this.azureTableName = checkNotNull(azureTableName, "azureTableName cannot be null");
//     }
// 
//     public AzureTableName getAzureTableName() {
//         return azureTableName;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (!(o instanceof TableType)) return false;
// 
//         TableType that = (TableType) o;
// 
//         if (azureTableName != that.azureTableName) return false;
//         if (partitionKey != null ? !partitionKey.equals(that.partitionKey) : that.partitionKey != null) return false;
//         if (rowKey != null ? !rowKey.equals(that.rowKey) : that.rowKey != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = azureTableName.hashCode();
//         result = 31 * result + (partitionKey != null ? partitionKey.hashCode() : 0);
//         result = 31 * result + (rowKey != null ? rowKey.hashCode() : 0);
//         return result;
//     }
// }


// Path: breakerbox-azure/src/main/java/com/yammer/breakerbox/azure/TableClient.java
import com.google.common.collect.ImmutableList;
import com.microsoft.azure.storage.StorageException;
import com.microsoft.azure.storage.table.*;
import com.yammer.breakerbox.azure.core.AzureTableName;
import com.yammer.breakerbox.azure.core.TableKey;
import com.yammer.breakerbox.azure.core.TableType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.ws.rs.core.Response;
import java.net.URISyntaxException;
import java.util.Optional;
import static com.google.common.base.Preconditions.checkNotNull;

    }

    public boolean insert(TableType entity) {
        try {
            return tableRefrence(entity.getAzureTableName())
                    .execute(TableOperation.insert(entity))
                    .getHttpStatusCode() == Response.Status.NO_CONTENT.getStatusCode();
        } catch (StorageException e) {
            LOG.warn("Error performing operation on Storage service", e);
        }
        throw new IllegalStateException("Error adding data in table " + entity.getAzureTableName());
    }

    public boolean insertOrReplace(TableType entity) {
        try {
            final TableResult tableResult = tableRefrence(entity.getAzureTableName())
                    .execute(TableOperation.insertOrReplace(entity));
            switch (Response.Status.fromStatusCode(tableResult.getHttpStatusCode())) {
                case CREATED:
                case NO_CONTENT:
                    return true;
                default:
                    return false;
            }
        } catch (StorageException e) {
            LOG.warn("Error performing operation on Storage service", e);
        }
        throw new IllegalStateException("Error insertOrReplace in table " + entity.getAzureTableName());
    }

    public <EntityType extends TableServiceEntity> Optional<EntityType> retrieve(TableKey tableKey) {