001/**
002 * Copyright (c) 2012, 2015, Credit Suisse (Anatole Tresch), Werner Keil and others by the @author tag.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005 * use this file except in compliance with the License. You may obtain a copy of
006 * the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013 * License for the specific language governing permissions and limitations under
014 * the License.
015 */
016package org.javamoney.moneta.spi;
017
018import java.net.URI;
019import java.util.Map;
020import java.util.Objects;
021
022import org.javamoney.moneta.spi.LoaderService.LoaderListener;
023import org.javamoney.moneta.spi.LoaderService.UpdatePolicy;
024
025/**
026 * To create this instance
027 * @see {@link LoadDataInformationBuilder}
028 * @author otaviojava
029 */
030public class LoadDataInformation {
031
032        private final String resourceId;
033
034        private final UpdatePolicy updatePolicy;
035
036    private final Map<String, String> properties;
037
038    private final LoaderListener loaderListener;
039
040    private final URI backupResource;
041
042    private final URI[] resourceLocations;
043
044    private final boolean startRemote;
045
046        LoadDataInformation(String resourceId, UpdatePolicy updatePolicy,
047                        Map<String, String> properties, LoaderListener loaderListener,
048                        URI backupResource, URI[] resourceLocations, boolean startRemote) {
049                this.resourceId = resourceId;
050                this.updatePolicy = updatePolicy;
051                this.properties = properties;
052                this.loaderListener = loaderListener;
053                this.backupResource = backupResource;
054                this.resourceLocations = resourceLocations;
055                this.startRemote = startRemote;
056        }
057
058        public String getResourceId() {
059                return resourceId;
060        }
061
062        public UpdatePolicy getUpdatePolicy() {
063                return updatePolicy;
064        }
065
066        public Map<String, String> getProperties() {
067                return properties;
068        }
069
070        public LoaderListener getLoaderListener() {
071                return loaderListener;
072        }
073
074        public URI getBackupResource() {
075                return backupResource;
076        }
077
078        public URI[] getResourceLocations() {
079                return resourceLocations;
080        }
081
082        public boolean isStartRemote() {
083                return startRemote;
084        }
085
086        @Override
087        public int hashCode() {
088                return Objects.hashCode(resourceId);
089        }
090
091        @Override
092        public boolean equals(Object obj) {
093                if (this == obj) {
094                        return true;
095                }
096                if (LoadDataInformation.class.isInstance(obj)) {
097                        LoadDataInformation other = LoadDataInformation.class.cast(obj);
098                        return Objects.equals(other.resourceId, resourceId);
099                }
100                return false;
101        }
102
103        @Override
104        public String toString() {
105                StringBuilder sb = new StringBuilder();
106                sb.append(LoadDataInformation.class.getName()).append('{')
107                .append(" resourceId: ").append(resourceId).append(',')
108                .append(" updatePolicy: ").append(updatePolicy).append(',')
109                .append(" properties: ").append(properties).append(',')
110                .append(" LoaderListener: ").append(loaderListener).append(',')
111                .append(" backupResource: ").append(backupResource).append(',')
112                .append(" resourceLocations: ").append(resourceLocations).append('}');
113                return sb.toString();
114        }
115
116}