@Override public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || !(obj instanceof PropertySimple)) { return false; } if (!super.equals(obj)) { return false; // superclass checks equality of the name fields } PropertySimple that = (PropertySimple) obj; // Treat empty string as if it were null See JBNADM-2715 String compareToA = ((this.stringValue != null) && (this.stringValue.length() == 0)) ? null : this.stringValue; String compareToB = ((that.stringValue != null) && (that.stringValue.length() == 0)) ? null : that.stringValue; if ((compareToA != null) ? (!compareToA.equals(compareToB)) : (compareToB != null)) { return false; } return true; }
/** * NOTE: An PropertyMap containing a null map is considered equal to a PropertyMap containing an empty map. */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || !(obj instanceof PropertyMap)) { return false; } if (!super.equals(obj)) { return false; // superclass checks equality of the name fields } PropertyMap that = (PropertyMap) obj; // NOTE: Use that.getMap(), rather than that.map, in case 'that' is a JPA/Hibernate proxy, to // force loading of the Map. if ((this.map == null) || this.map.isEmpty()) { return (that.getMap() == null) || that.getMap().isEmpty(); } return this.map.equals(that.getMap()); }
/** * NOTE: An PropertyList containing a null list is considered equal to a PropertyList containing an empty list. */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if ((obj == null) || !(obj instanceof PropertyList)) { return false; } if (!super.equals(obj)) { return false; // superclass checks equality of the name fields } PropertyList that = (PropertyList) obj; if ((this.list == null) || this.list.isEmpty()) { // NOTE: Use that.getList(), rather than that.list, in case 'that' is a JPA/Hibernate proxy, to // force loading of the List. return (that.getList() == null) || that.getList().isEmpty(); } return this.list.containsAll(that.getList()) && that.getList().containsAll(this.list); }
private Configuration mergeExistingResourcePluginConfiguration(Resource resource, Configuration pluginConfig) { // If there is no update necessary just return the current plugin config of the existing resource Configuration result = resource.getPluginConfiguration(); ConfigurationDefinition configDef = resource.getResourceType().getPluginConfigurationDefinition(); if (null == configDef) { return result; } Configuration existingPluginConfig = resource.getPluginConfiguration().deepCopy(false); Configuration defaultPluginConfig = ConfigurationUtility.createDefaultConfiguration(configDef); boolean configChanged = false; // for each property, update the existing plugin config if discovery has set a non-default value for (String propertyName : pluginConfig.getAllProperties().keySet()) { Property discoveredProp = pluginConfig.get(propertyName); Property defaultProp = defaultPluginConfig.get(propertyName); if (!discoveredProp.equals(defaultProp)) { if (log.isDebugEnabled()) { log.debug("Discovery reported a new version of " + resource + ". Updating value of config property" + " from [" + existingPluginConfig.get(propertyName) + "] to [" + discoveredProp + "]."); } existingPluginConfig.put(discoveredProp); configChanged = true; } } if (configChanged) { result = mergeExistingResourcePluginConfigurationOnServer(resource, existingPluginConfig); } return result; }