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.Arrays; 020import java.util.Map; 021import java.util.Objects; 022 023import org.javamoney.moneta.spi.LoaderService.LoaderListener; 024import org.javamoney.moneta.spi.LoaderService.UpdatePolicy; 025 026/** 027 * To create this instance 028 * @see LoadDataInformationBuilder 029 * @author otaviojava 030 */ 031public class LoadDataInformation { 032 033 private final String resourceId; 034 035 private final UpdatePolicy updatePolicy; 036 037 private final Map<String, String> properties; 038 039 private final LoaderListener loaderListener; 040 041 private final URI backupResource; 042 043 private final URI[] resourceLocations; 044 045 private final boolean startRemote; 046 047 LoadDataInformation(String resourceId, UpdatePolicy updatePolicy, 048 Map<String, String> properties, LoaderListener loaderListener, 049 URI backupResource, URI[] resourceLocations, boolean startRemote) { 050 this.resourceId = resourceId; 051 this.updatePolicy = updatePolicy; 052 this.properties = properties; 053 this.loaderListener = loaderListener; 054 this.backupResource = backupResource; 055 this.resourceLocations = resourceLocations; 056 this.startRemote = startRemote; 057 } 058 059 public String getResourceId() { 060 return resourceId; 061 } 062 063 public UpdatePolicy getUpdatePolicy() { 064 return updatePolicy; 065 } 066 067 public Map<String, String> getProperties() { 068 return properties; 069 } 070 071 public LoaderListener getLoaderListener() { 072 return loaderListener; 073 } 074 075 public URI getBackupResource() { 076 return backupResource; 077 } 078 079 public URI[] getResourceLocations() { 080 return resourceLocations; 081 } 082 083 public boolean isStartRemote() { 084 return startRemote; 085 } 086 087 @Override 088 public int hashCode() { 089 return Objects.hashCode(resourceId); 090 } 091 092 @Override 093 public boolean equals(Object obj) { 094 if (this == obj) { 095 return true; 096 } 097 if (LoadDataInformation.class.isInstance(obj)) { 098 LoadDataInformation other = LoadDataInformation.class.cast(obj); 099 return Objects.equals(other.resourceId, resourceId); 100 } 101 return false; 102 } 103 104 @Override 105 public String toString() { 106 String sb = LoadDataInformation.class.getName() + '{' + 107 " resourceId: " + resourceId + ',' + 108 " updatePolicy: " + updatePolicy + ',' + 109 " properties: " + properties + ',' + 110 " LoaderListener: " + loaderListener + ',' + 111 " backupResource: " + backupResource + ',' + 112 " resourceLocations: " + Arrays.toString(resourceLocations) + '}'; 113 return sb; 114 } 115 116}