All Downloads are FREE. Search and download functionalities are using the official Maven repository.

syncloud.storage.StorageKey Maven / Gradle / Ivy

The newest version!
package syncloud.storage;

public class StorageKey {
    private String storageId;
    private User user;

    public StorageKey(String storageId, User user) throws StorageException {

        validate(user);

        this.storageId = storageId;
        this.user = user;
    }

    private void validate(User user) throws StorageException {
        if (user == null)
            throw new StorageException("user cannot be empty");
    }

    public String getStorageId() {
        return storageId;
    }

    public User getUser() {
        return user;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        StorageKey that = (StorageKey) o;

        if (storageId != null ? !storageId.equals(that.storageId) : that.storageId != null) return false;
        if (user != null ? !user.equals(that.user) : that.user != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = storageId != null ? storageId.hashCode() : 0;
        result = 31 * result + (user != null ? user.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "StorageKey{" +
                "storageId=" + storageId +
                ", user=" + user +
                '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy