attributeMap.put(attribute.getName().toLowerCase(), attribute.getValue());
/** * Gets attribute value by name from the storage object instance. * * @param attributeName the attribute name (case insensitive) * @param storage the storage * @param required specifies whether the attribute value is mandatory * * @return the attribute value from the attribute with the attribute name, or {@code null} if this list contains no attribute with this attribute name */ public String getStorageAttributeValueByName(String attributeName, Storage storage, Boolean required) { String attributeValue = null; for (Attribute attribute : storage.getAttributes()) { if (attribute.getName().equalsIgnoreCase(attributeName)) { attributeValue = attribute.getValue(); break; } } if (required && StringUtils.isBlank(attributeValue)) { throw new IllegalStateException(String.format("Attribute \"%s\" for \"%s\" storage must be configured.", attributeName, storage.getName())); } return attributeValue; }
/** * Gets attribute value by name from the storage object instance. * * @param attributeName the attribute name (case insensitive) * @param storage the storage * @param required specifies whether the attribute value is mandatory * * @return the attribute value from the attribute with the attribute name, or {@code null} if this list contains no attribute with this attribute name */ public String getStorageAttributeValueByName(String attributeName, Storage storage, Boolean required) { String attributeValue = null; for (Attribute attribute : storage.getAttributes()) { if (attribute.getName().equalsIgnoreCase(attributeName)) { attributeValue = attribute.getValue(); break; } } if (required && StringUtils.isBlank(attributeValue)) { throw new IllegalStateException(String.format("Attribute \"%s\" for \"%s\" storage must be configured.", attributeName, storage.getName())); } return attributeValue; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theName; theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); strategy.appendField(locator, this, "value", buffer, theValue, (this.value!= null)); } return buffer; }
/** * Validates the attributes. * * @param attributes the attributes to validate. Null shouldn't be specified. * @return the validated attribute map * @throws IllegalArgumentException if any invalid attributes were found. */ public Map<String, String> validateAttributes(List<Attribute> attributes) throws IllegalArgumentException { // Validate attributes if they are specified. Map<String, String> attributeNameValidationMap = new HashMap<>(); if (!CollectionUtils.isEmpty(attributes)) { for (Attribute attribute : attributes) { attribute.setName(alternateKeyHelper.validateStringParameter("An", "attribute name", attribute.getName())); // Ensure the attribute key isn't a duplicate by using a map with a "lowercase" name as the key for case insensitivity. String validationMapKey = attribute.getName().toLowerCase(); if (attributeNameValidationMap.containsKey(validationMapKey)) { throw new IllegalArgumentException("Duplicate attribute name found: " + attribute.getName()); } attributeNameValidationMap.put(validationMapKey, attribute.getValue()); } } return attributeNameValidationMap; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theName; theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); strategy.appendField(locator, this, "value", buffer, theValue, (this.value!= null)); } return buffer; }
/** * Validates the attributes. * * @param attributes the attributes to validate. Null shouldn't be specified. * @return the validated attribute map * @throws IllegalArgumentException if any invalid attributes were found. */ public Map<String, String> validateAttributes(List<Attribute> attributes) throws IllegalArgumentException { // Validate attributes if they are specified. Map<String, String> attributeNameValidationMap = new HashMap<>(); if (!CollectionUtils.isEmpty(attributes)) { for (Attribute attribute : attributes) { attribute.setName(alternateKeyHelper.validateStringParameter("An", "attribute name", attribute.getName())); // Ensure the attribute key isn't a duplicate by using a map with a "lowercase" name as the key for case insensitivity. String validationMapKey = attribute.getName().toLowerCase(); if (attributeNameValidationMap.containsKey(validationMapKey)) { throw new IllegalArgumentException("Duplicate attribute name found: " + attribute.getName()); } attributeNameValidationMap.put(validationMapKey, attribute.getValue()); } } return attributeNameValidationMap; }
public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy2 strategy) { { String theName; theName = this.getName(); strategy.appendField(locator, this, "name", buffer, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); strategy.appendField(locator, this, "value", buffer, theValue, (this.value!= null)); } return buffer; }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy2 strategy) { if ((object == null)||(this.getClass()!= object.getClass())) { return false; } if (this == object) { return true; } final Attribute that = ((Attribute) object); { String lhsName; lhsName = this.getName(); String rhsName; rhsName = that.getName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "name", lhsName), LocatorUtils.property(thatLocator, "name", rhsName), lhsName, rhsName, (this.name!= null), (that.name!= null))) { return false; } } { String lhsValue; lhsValue = this.getValue(); String rhsValue; rhsValue = that.getValue(); if (!strategy.equals(LocatorUtils.property(thisLocator, "value", lhsValue), LocatorUtils.property(thatLocator, "value", rhsValue), lhsValue, rhsValue, (this.value!= null), (that.value!= null))) { return false; } } return true; }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy2 strategy) { if ((object == null)||(this.getClass()!= object.getClass())) { return false; } if (this == object) { return true; } final Attribute that = ((Attribute) object); { String lhsName; lhsName = this.getName(); String rhsName; rhsName = that.getName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "name", lhsName), LocatorUtils.property(thatLocator, "name", rhsName), lhsName, rhsName, (this.name!= null), (that.name!= null))) { return false; } } { String lhsValue; lhsValue = this.getValue(); String rhsValue; rhsValue = that.getValue(); if (!strategy.equals(LocatorUtils.property(thisLocator, "value", lhsValue), LocatorUtils.property(thatLocator, "value", rhsValue), lhsValue, rhsValue, (this.value!= null), (that.value!= null))) { return false; } } return true; }
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy2 strategy) { if ((object == null)||(this.getClass()!= object.getClass())) { return false; } if (this == object) { return true; } final Attribute that = ((Attribute) object); { String lhsName; lhsName = this.getName(); String rhsName; rhsName = that.getName(); if (!strategy.equals(LocatorUtils.property(thisLocator, "name", lhsName), LocatorUtils.property(thatLocator, "name", rhsName), lhsName, rhsName, (this.name!= null), (that.name!= null))) { return false; } } { String lhsValue; lhsValue = this.getValue(); String rhsValue; rhsValue = that.getValue(); if (!strategy.equals(LocatorUtils.property(thisLocator, "value", lhsValue), LocatorUtils.property(thatLocator, "value", rhsValue), lhsValue, rhsValue, (this.value!= null), (that.value!= null))) { return false; } } return true; }
public int hashCode(ObjectLocator locator, HashCodeStrategy2 strategy) { int currentHashCode = 1; { String theName; theName = this.getName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "name", theName), currentHashCode, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "value", theValue), currentHashCode, theValue, (this.value!= null)); } return currentHashCode; }
/** * Validates a list of Attributes against the expected values. * * @param expectedAttributes the list of expected Attributes * @param actualAttributes the list of actual Attributes to be validated */ public void validateAttributes(List<Attribute> expectedAttributes, List<Attribute> actualAttributes) { assertEquals(expectedAttributes.size(), actualAttributes.size()); for (int i = 0; i < expectedAttributes.size(); i++) { Attribute expectedAttribute = expectedAttributes.get(i); Attribute actualAttribute = actualAttributes.get(i); assertEquals(expectedAttribute.getName(), actualAttribute.getName()); assertEquals(expectedAttribute.getValue(), actualAttribute.getValue()); } } }
public int hashCode(ObjectLocator locator, HashCodeStrategy2 strategy) { int currentHashCode = 1; { String theName; theName = this.getName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "name", theName), currentHashCode, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "value", theValue), currentHashCode, theValue, (this.value!= null)); } return currentHashCode; }
public int hashCode(ObjectLocator locator, HashCodeStrategy2 strategy) { int currentHashCode = 1; { String theName; theName = this.getName(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "name", theName), currentHashCode, theName, (this.name!= null)); } { String theValue; theValue = this.getValue(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "value", theValue), currentHashCode, theValue, (this.value!= null)); } return currentHashCode; }
attributeEntity.setStorage(storageEntity); attributeEntity.setName(attribute.getName()); attributeEntity.setValue(attribute.getValue());
if (valueShouldBeCopiedAndSet == Boolean.TRUE) { String sourceValue; sourceValue = this.getValue(); String copyValue = ((String) strategy.copy(LocatorUtils.property(locator, "value", sourceValue), sourceValue, (this.value!= null))); copy.setValue(copyValue);
/** * Creates and persists a new storage entity. * * @param storageName the storage name * @param storagePlatformEntity the storage platform entity * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName, StoragePlatformEntity storagePlatformEntity, List<Attribute> attributes) { StorageEntity storageEntity = new StorageEntity(); storageEntity.setName(storageName); storageEntity.setStoragePlatform(storagePlatformEntity); // Create the attributes if they are specified. if (!CollectionUtils.isEmpty(attributes)) { List<StorageAttributeEntity> attributeEntities = new ArrayList<>(); storageEntity.setAttributes(attributeEntities); for (Attribute attribute : attributes) { StorageAttributeEntity attributeEntity = new StorageAttributeEntity(); attributeEntities.add(attributeEntity); attributeEntity.setStorage(storageEntity); attributeEntity.setName(attribute.getName()); attributeEntity.setValue(attribute.getValue()); } } return storageDao.saveAndRefresh(storageEntity); }
assertEquals("storageName", resultDto.getStorageName()); HashMap<String, String> expectedAttributes = new HashMap<>(); expectedAttributes.put(attribute.getName(), attribute.getValue()); assertEquals(expectedAttributes, resultDto.getAttributes()); assertEquals(new ArrayList<>(), resultDto.getBusinessObjectDataParents());
for (Attribute attribute : getTestAttributes()) attributes.put(attribute.getName(), attribute.getValue());