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

edu.stanford.protege.webprotege.app.ApplicationPreferences Maven / Gradle / Ivy

There is a newer version: 2.0.2-WHO
Show newest version
package edu.stanford.protege.webprotege.app;

import com.google.common.base.Objects;

import javax.annotation.Nonnull;

import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 17 Mar 2017
 *
 * An object that holds application preferences that are stored in the database.
 */
public class ApplicationPreferences {

    public static final String ID = "Preferences";

    @SuppressWarnings("unused")
    private final String id = ID;

    private final String applicationName;

    private final String systemNotificationEmailAddress;

    private final ApplicationLocation applicationLocation;

    private final long maxUploadSize;
    
    public ApplicationPreferences(@Nonnull String applicationName,
                                  @Nonnull String systemNotificationEmailAddress,
                                  @Nonnull ApplicationLocation applicationLocation,
                                  long maxUploadSize) {
        this.applicationName = checkNotNull(applicationName);
        this.systemNotificationEmailAddress = checkNotNull(systemNotificationEmailAddress);
        this.applicationLocation = checkNotNull(applicationLocation);
        this.maxUploadSize = maxUploadSize;
    }

    /**
     * Gets the application name.
     * @return A string representing the application name.
     */
    @Nonnull
    public String getApplicationName() {
        return applicationName;
    }

    /**
     * Gets the administrator's email address.
     * @return A string representing the admins email address.  May be empty.
     */
    @Nonnull
    public String getSystemNotificationEmailAddress() {
        return systemNotificationEmailAddress;
    }

    /**
     * Get the application location.
     * @return The location of the application.  This is used in links in notification emails.
     */
    @Nonnull
    public ApplicationLocation getApplicationLocation() {
        return applicationLocation;
    }

    /**
     * Gets the maximum file upload size.
     * @return The maximum file upload size.
     */
    public long getMaxUploadSize() {
        return maxUploadSize;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(applicationName,
                systemNotificationEmailAddress,
                                applicationLocation,
                                maxUploadSize);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof ApplicationPreferences)) {
            return false;
        }
        ApplicationPreferences other = (ApplicationPreferences) obj;
        return this.applicationName.equals(other.applicationName)
                && this.systemNotificationEmailAddress.equals(other.systemNotificationEmailAddress)
                && this.applicationLocation.equals(other.applicationLocation)
                && this.maxUploadSize == other.maxUploadSize;
    }


    @Override
    public String toString() {
        return toStringHelper("ApplicationPreferences" )
                .addValue(applicationName)
                .add("systemNotificationEmail", systemNotificationEmailAddress)
                .addValue(applicationLocation)
                .toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy