/** * Creates a new GoogleBaseAttribute with a name and no type. * * @param name */ public GoogleBaseAttribute(String name) { this(new GoogleBaseAttributeId(name, null), null); }
/** * Gets the name of the attribute this histogram describes. * * @return attribute name */ public String getAttributeName() { return attributeId.getName(); }
/** * Gets the type of the attribute this histogram describes. * * @return attribute type */ public GoogleBaseAttributeType getAttributeType() { return attributeId.getType(); }
@Override public int hashCode() { int retval = 27 + attributeId.hashCode(); if (textValue != null) { retval += 49 * textValue.hashCode(); } if (subElements != null) { retval += subElements.hashCode(); } return retval; }
@Override public boolean equals(Object o) { if (o == null || !(o instanceof GoogleBaseAttribute)) { return false; } GoogleBaseAttribute other = (GoogleBaseAttribute)o; return attributeId.equals(other.attributeId) && privateAccess == other.privateAccess && equalsMaybeNull(textValue, other.textValue) && equalsMaybeNull(subElements, other.subElements); } private static boolean equalsMaybeNull(Object a, Object b) {
@Override public int hashCode() { int retval = 27 + attributeId.hashCode(); if (textValue != null) { retval += 49 * textValue.hashCode(); } if (subElements != null) { retval += subElements.hashCode(); } return retval; }
@Override public boolean equals(Object o) { if (o == null || !(o instanceof GoogleBaseAttribute)) { return false; } GoogleBaseAttribute other = (GoogleBaseAttribute)o; return attributeId.equals(other.attributeId) && privateAccess == other.privateAccess && equalsMaybeNull(textValue, other.textValue) && equalsMaybeNull(subElements, other.subElements); } private static boolean equalsMaybeNull(Object a, Object b) {
/** * Creates a new GoogleBaseAttribute with a name and no type. * * @param name */ public GoogleBaseAttribute(String name) { this(new GoogleBaseAttributeId(name, null), null); }
/** * Gets the type of the attribute this histogram describes. * * @return attribute type */ public GoogleBaseAttributeType getAttributeType() { return attributeId.getType(); }
/** * Gets the name of the attribute this histogram describes. * * @return attribute name */ public String getAttributeName() { return attributeId.getName(); }
/** * Creates and initializes an AttributeHistogram. * * @param attributeName attribute name * @param attributeType attribute type */ public AttributeHistogram(String attributeName, GoogleBaseAttributeType attributeType) { attributeId = new GoogleBaseAttributeId(attributeName, attributeType); }
/** Gets the type of the attribute, or null. */ public GoogleBaseAttributeType getType() { return attributeId.getType(); }
/** Gets the attribute name. */ public String getName() { return attributeId.getName(); }
/** Generate the XML representation for this tag. */ public void generate(XmlWriter w, ExtensionProfile extProfile) throws IOException { if (attributes.isEmpty()) { // Nothing to write return; } w.startElement(GoogleBaseNamespaces.GM, "attributes", null, null); w.startRepeatingElement(); for (GmAttribute attribute : attributes) { List<XmlWriter.Attribute> attributes = new ArrayList<XmlWriter.Attribute>(); GoogleBaseAttributeId id = attribute.getAttributeId(); attributes.add(new XmlWriter.Attribute("name", id.getName())); if (id.getType() != null) { attributes.add(new XmlWriter.Attribute("type", id.getType().getName())); } if (attribute.getImportance() != null) { attributes.add(new XmlWriter.Attribute("importance", attribute.getImportance().getXmlValue())); } w.simpleElement(GoogleBaseNamespaces.GM, "attribute", attributes, null); } w.endRepeatingElement(); w.endElement(); }
/** * Creates and initializes an AttributeHistogram. * * @param attributeName attribute name * @param attributeType attribute type */ public AttributeHistogram(String attributeName, GoogleBaseAttributeType attributeType) { attributeId = new GoogleBaseAttributeId(attributeName, attributeType); }
/** Gets the type of the attribute, or null. */ public GoogleBaseAttributeType getType() { return attributeId.getType(); }