@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getAlternateNameEncoding() == null) ? 0 : getAlternateNameEncoding().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getAlternateValueEncoding() == null) ? 0 : getAlternateValueEncoding().hashCode()); return hashCode; }
private void addProperty(Item item) { Iterator<Attribute> attrs = item.getAttributes().iterator(); String prop = ""; String value = ""; String dc = ""; while (attrs.hasNext()) { Attribute att = attrs.next(); if (att.getName().equals(Attributes.PROPERTY)) prop = att.getValue(); else if (att.getName().equals(Attributes.PROPERTY_VALUE)) value = att.getValue(); else if (att.getName().equals(Attributes.REGION)) dc = att.getValue(); } // Ignore, if not this region if (StringUtils.isNotBlank(dc) && !dc.equals(getRegion())) return; // Override only if region is specified if (data.containsKey(prop) && StringUtils.isBlank(dc)) return; data.put(prop, value); }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getName() != null) sb.append("Name: ").append(getName()).append(","); if (getAlternateNameEncoding() != null) sb.append("AlternateNameEncoding: ").append(getAlternateNameEncoding()).append(","); if (getValue() != null) sb.append("Value: ").append(getValue()).append(","); if (getAlternateValueEncoding() != null) sb.append("AlternateValueEncoding: ").append(getAlternateValueEncoding()); sb.append("}"); return sb.toString(); }
/** * Convert a simpledb item to PriamInstance * * @param item * @return */ public PriamInstance transform(Item item) { PriamInstance ins = new PriamInstance(); for (Attribute att : item.getAttributes()) { if (att.getName().equals(Attributes.INSTANCE_ID)) ins.setInstanceId(att.getValue()); else if (att.getName().equals(Attributes.TOKEN)) ins.setToken(att.getValue()); else if (att.getName().equals(Attributes.APP_ID)) ins.setApp(att.getValue()); else if (att.getName().equals(Attributes.ID)) ins.setId(Integer.parseInt(att.getValue())); else if (att.getName().equals(Attributes.AVAILABILITY_ZONE)) ins.setRac(att.getValue()); else if (att.getName().equals(Attributes.ELASTIC_IP)) ins.setHostIP(att.getValue()); else if (att.getName().equals(Attributes.HOSTNAME)) ins.setHost(att.getValue()); else if (att.getName().equals(Attributes.LOCATION)) ins.setDC(att.getValue()); else if (att.getName().equals(Attributes.UPDATE_TS)) ins.setUpdatetime(Long.parseLong(att.getValue())); } return ins; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Attribute == false) return false; Attribute other = (Attribute) obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getAlternateNameEncoding() == null ^ this.getAlternateNameEncoding() == null) return false; if (other.getAlternateNameEncoding() != null && other.getAlternateNameEncoding().equals(this.getAlternateNameEncoding()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; if (other.getAlternateValueEncoding() == null ^ this.getAlternateValueEncoding() == null) return false; if (other.getAlternateValueEncoding() != null && other.getAlternateValueEncoding().equals(this.getAlternateValueEncoding()) == false) return false; return true; }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getName() != null) sb.append("Name: " + getName() + ","); if (getAlternateNameEncoding() != null) sb.append("AlternateNameEncoding: " + getAlternateNameEncoding() + ","); if (getValue() != null) sb.append("Value: " + getValue() + ","); if (getAlternateValueEncoding() != null) sb.append("AlternateValueEncoding: " + getAlternateValueEncoding() ); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getAlternateNameEncoding() == null) ? 0 : getAlternateNameEncoding().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getAlternateValueEncoding() == null) ? 0 : getAlternateValueEncoding().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof Attribute == false) return false; Attribute other = (Attribute)obj; if (other.getName() == null ^ this.getName() == null) return false; if (other.getName() != null && other.getName().equals(this.getName()) == false) return false; if (other.getAlternateNameEncoding() == null ^ this.getAlternateNameEncoding() == null) return false; if (other.getAlternateNameEncoding() != null && other.getAlternateNameEncoding().equals(this.getAlternateNameEncoding()) == false) return false; if (other.getValue() == null ^ this.getValue() == null) return false; if (other.getValue() != null && other.getValue().equals(this.getValue()) == false) return false; if (other.getAlternateValueEncoding() == null ^ this.getAlternateValueEncoding() == null) return false; if (other.getAlternateValueEncoding() != null && other.getAlternateValueEncoding().equals(this.getAlternateValueEncoding()) == false) return false; return true; }
private static String getValueToSet(List<Attribute> atts, String propertyName, String columnName) { if(columnName != null) propertyName = columnName; for (Attribute att : atts) { String attName = att.getName(); if (attName.equals(propertyName)) { String val = att.getValue(); return val; } } return null; }
private Map<String, List<String>> createAttributeMap(List<Attribute> attributes) { Map<String, List<String>> map = new LinkedHashMap<String, List<String>>(); for (Attribute attribute : attributes) { if (map.get(attribute.getName()) == null) { List<String> list = new ArrayList<String>(); list.add(attribute.getValue()); map.put(attribute.getName(), list); } else { map.get(attribute.getName()).add(attribute.getValue()); } } return map; } }
private static Collection<String> getValuesToSet(List<Attribute> atts, String propertyName, String columnName) { Collection<String> values = new ArrayList<String>(); if(columnName != null) propertyName = columnName; for (Attribute att : atts) { String attName = att.getName(); if (attName.equals(propertyName)) { values.add(att.getValue()); } } return values; }
private static Set<String> getForeignKeys(EntityManagerSimpleJPA em, PersistentProperty getter, String columnName, List<Attribute> atts) { String fkAttName = columnName != null ? columnName : NamingHelper.foreignKey(getter.getFieldName()); HashSet<String> keys = new HashSet<String>(atts.size()); for (Attribute att : atts) { if (att.getName().equals(fkAttName)) { keys.add(att.getValue()); } } return keys; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); hashCode = prime * hashCode + ((getAlternateNameEncoding() == null) ? 0 : getAlternateNameEncoding().hashCode()); hashCode = prime * hashCode + ((getValue() == null) ? 0 : getValue().hashCode()); hashCode = prime * hashCode + ((getAlternateValueEncoding() == null) ? 0 : getAlternateValueEncoding().hashCode()); return hashCode; }
@Override public SearchItem apply(Item item) { SearchItem si = new SearchItem(item.getName()); item.getAttributes().forEach(attr -> si.addAttribute(attr.getName(), attr.getValue())); return si; } }