/** * Finds all attribute names except those provided as arguments. * @return list of all attributes except those provided as arguments. */ public Set<String> getAttributeNamesSkip(String ... names) { Set<String> attributes = new CaseInsensitiveSet(getAttributeNames()); for (String name : names) { attributes.remove(name); } return attributes; }
public static Set<String> attributeNames(Class<? extends Model> clazz) { return metaModelOf(clazz).getAttributeNames(); }
/** * Checks if this model has a named attribute that has the same name as argument. * * Throws <code>IllegalArgumentException</code> in case it does not find it. * * @param attribute name of attribute or association target. */ protected void checkAttribute(String attribute) { if (!hasAttribute(attribute)) { String sb = "Attribute: '" + attribute + "' is not defined in model: '" + getModelClass() + ". " + "Available attributes: " +getAttributeNames(); throw new IllegalArgumentException(sb); } }
/** * Finds all attribute names except for id. * * @return all attribute names except for id. */ public Set<String> getAttributeNamesSkipId() { if (attributeNamesNoId == null) {//no one cares about unfortunate multi-threading timing with 2 instances created //if someone does, use DCL with volatile Set<String> attributesNames = new CaseInsensitiveSet(getAttributeNames()); attributesNames.remove(getIdName()); attributeNamesNoId = attributesNames; } return attributeNamesNoId; }
Set<String> attributeNames = metaModelLocal.getAttributeNames(); for (Map.Entry<String, Object> entry : attributesMap.entrySet()) { if (attributeNames.contains(entry.getKey()) ) {
/** * Finds all attribute names except those provided as arguments. * @return list of all attributes except those provided as arguments. */ public Set<String> getAttributeNamesSkip(String ... names) { Set<String> attributes = new CaseInsensitiveSet(getAttributeNames()); for (String name : names) { attributes.remove(name); } return attributes; }
/** * Finds all attribute names except those provided as arguments. * @return list of all attributes except those provided as arguments. */ public Set<String> getAttributeNamesSkip(String ... names) { Set<String> attributes = new CaseInsensitiveSet(getAttributeNames()); for (String name : names) { attributes.remove(name); } return attributes; }
/** * Finds all attribute names except those provided as arguments. * * @return list of all attributes except those provided as arguments. */ public Set<String> getAttributeNamesSkip(String... names) { Set<String> attributes = new CaseInsensitiveSet(getAttributeNames()); for (String name : names) { attributes.remove(name); } return attributes; }
public static Set<String> attributeNames(Class<? extends Model> clazz) { return metaModelOf(clazz).getAttributeNames(); }
public static Set<String> attributeNames(Class<? extends Model> clazz) { return metaModelOf(clazz).getAttributeNames(); }
/** * Finds all attribute names except for id. * * @return all attribute names except for id. */ public Set<String> getAttributeNamesSkipId() { if (attributeNamesNoId == null) {//no one cares about unfortunate multi-threading timing with 2 instances created //if someone does, use DCL with volatile Set<String> attributes = new CaseInsensitiveSet(getAttributeNames()); attributes.remove(getIdName()); attributeNamesNoId = attributes; } return attributeNamesNoId; }
/** * Checks if this model has a named attribute that has the same name as argument. * * Throws <code>IllegalArgumentException</code> in case it does not find it. * * @param attribute name of attribute or association target. */ protected void checkAttribute(String attribute) { if (!hasAttribute(attribute)) { String sb = "Attribute: '" + attribute + "' is not defined in model: '" + getModelClass() + ". " + "Available attributes: " +getAttributeNames(); throw new IllegalArgumentException(sb); } }
/** * Checks if this model has a named attribute that has the same name as argument. * <p> * Throws <code>IllegalArgumentException</code> in case it does not find it. * * @param attribute name of attribute or association target. */ protected void checkAttribute(String attribute) { if (!hasAttribute(attribute)) { String sb = "Attribute: '" + attribute + "' is not defined in model: '" + getModelClass() + ". " + "Available attributes: " + getAttributeNames(); throw new IllegalArgumentException(sb); } }
/** * Finds all attribute names except for id. * * @return all attribute names except for id. */ public Set<String> getAttributeNamesSkipId() { if (attributeNamesNoId == null) {//no one cares about unfortunate multi-threading timing with 2 instances created //if someone does, use DCL with volatile Set<String> attributesNames = new CaseInsensitiveSet(getAttributeNames()); attributesNames.remove(getIdName()); attributeNamesNoId = attributesNames; } return attributeNamesNoId; }
/** * Finds all attribute names except for id. * * @return all attribute names except for id. */ public Set<String> getAttributeNamesSkipId() { if (attributeNamesNoId == null) {//no one cares about unfortunate multi-threading timing with 2 instances created //if someone does, use DCL with volatile Set<String> attributesNames = new CaseInsensitiveSet(getAttributeNames()); attributesNames.remove(getIdName()); attributeNamesNoId = attributesNames; } return attributeNamesNoId; }
/** * Checks if this model has a named attribute or association whose target has the same name as argument. * Throws <code>IllegalArgumentException</code> in case it does not find either one. * * @param attributeOrAssociation name of attribute or association target. */ protected void checkAttributeOrAssociation(String attributeOrAssociation) { if (!hasAttribute(attributeOrAssociation)) { boolean contains = false; for (Association association : associations) { if (association.getTarget().equalsIgnoreCase(attributeOrAssociation)) { contains = true; break; } } if (!contains) { StringBuilder sb = new StringBuilder().append("Attribute: '").append(attributeOrAssociation) .append("' is not defined in model: '").append(getModelClass()) .append("' and also, did not find an association by the same name, available attributes: ") .append(getAttributeNames()); if (!associations.isEmpty()) { sb.append("\nAvailable associations:\n"); join(sb, associations, "\n"); } throw new IllegalArgumentException(sb.toString()); } } }
/** * Hydrates a this instance of model from a map. Only picks values from a map that match * this instance's attribute names, while ignoring the others. * * @param attributesMap map containing values for this instance. */ protected void hydrate(Map<String, Object> attributesMap, boolean fireAfterLoad) { Set<String> attributeNames = metaModelLocal.getAttributeNames(); for (Map.Entry<String, Object> entry : attributesMap.entrySet()) { if (attributeNames.contains(entry.getKey())) { if (entry.getValue() instanceof Clob && metaModelLocal.cached()) { this.attributes.put(entry.getKey(), Convert.toString(entry.getValue())); } else { this.attributes.put(entry.getKey(), metaModelLocal.getDialect().overrideDriverTypeConversion( metaModelLocal, entry.getKey(), entry.getValue())); } } } if (getCompositeKeys() != null){ compositeKeyPersisted = true; } if(fireAfterLoad){ fireAfterLoad(); } }
/** * Hydrates a this instance of model from a map. Only picks values from a map that match * this instance's attribute names, while ignoring the others. * * @param attributesMap map containing values for this instance. */ protected void hydrate(Map<String, Object> attributesMap) { Set<String> attributeNames = getMetaModelLocal().getAttributeNames(); for (Map.Entry<String, Object> entry : attributesMap.entrySet()) { if (attributeNames.contains(entry.getKey())) { if (entry.getValue() instanceof Clob && getMetaModelLocal().cached()) { this.attributes.put(entry.getKey(), Convert.toString(entry.getValue())); } else { this.attributes.put(entry.getKey(), getMetaModelLocal().getDialect().overrideDriverTypeConversion( getMetaModelLocal(), entry.getKey(), entry.getValue())); } } } }