@Override public boolean hasAttributeDefinedDirectly(@Nonnull AtrRef<?, ?, ?> atr) { AttrInternalRef ref = getDictionary().getAttributeReferenceOrException(atr); return getAttributeDefinedLocally(ref) != null; }
@Nonnull final static SType<?> getAttributeDefinedHierarchy(@Nonnull SType<?> type, @Nonnull AttrInternalRef ref) { Objects.requireNonNull(type); Objects.requireNonNull(ref); for (SType<?> current = type; current != null; current = current.getSuperType()) { SType<?> att = current.getAttributeDefinedLocally(ref); if (att != null) { return att; } } throw new SingularFormException("Não existe atributo '" + ref.getName() + "' em " + type.getName(), type); }
final SType<?> getAttributeDefinedHierarchy(String fullName) { for (SType<?> current = this; current != null; current = current.superType) { SType<?> att = current.getAttributeDefinedLocally(fullName); if (att != null) { return att; } } throw new SingularFormException("Não existe atributo '" + fullName + "' em " + getName(), this); }
public SInstance getCreating(String attributePath) { SInstance entry = get(attributePath); if (entry != null) { return entry; } for (SType<?> current = owner; current != null; current = current.getSuperType()) { SType<?> attrType = current.getAttributeDefinedLocally(attributePath); if (attrType != null) { SInstance attrInstance = attrType.newAttributeInstanceFor(owner); if (attributes == null) { attributes = new LinkedHashMap<>(); } attributes.put(attributePath, attrInstance); return attrInstance; } } if(owner != null) { throw new SingularFormException( "Não existe o atributo '" + attributePath + "' definido em '" + owner.getName() + "' ou nos tipos extendidos"); } else { throw new SingularFormException("Não existe o atributo '" + attributePath + "'"); } }
@Nonnull protected SInstance createNewAttribute(@Nonnull AttrInternalRef ref) { for (SType<?> current = getOwner(); current != null; current = current.getSuperType()) { SType<?> attrType = current.getAttributeDefinedLocally(ref); if (attrType != null) { return set(ref, attrType.newAttributeInstanceFor(getOwner())); } } throw new SingularFormException( "Não existe o atributo '" + ref.getName() + "' definido em '" + getOwner().getName() + "' ou nos tipos pai do mesmo", getOwner()); }