private SDictionary dictionary() { return root.getDictionary(); }
private SDictionary dictionary() { return root.getDictionary(); }
public SType<?> getType(SInstance instance) { return typeName == null ? null : instance.getDictionary().getType(typeName); }
public SType<?> getType(SInstance instance) { return typeName == null ? null : instance.getDictionary().getType(typeName); }
@Nullable @Override public final <T> T getAttributeValue(@Nonnull AtrRef<?, ?, ?> atr, @Nullable Class<T> resultClass) { return getAttributeValue(getDictionary().getAttributeReferenceOrException(atr), resultClass); }
/** * Looks for the best match implementation of the aspect being request. * <p>To understand the registration and retrieval process see {@link AspectRef}.</p> */ @Nonnull public <T> Optional<T> getAspect(@Nonnull AspectRef<T> aspectRef) { return getDictionary().getMasterAspectRegistry().getAspect(this, aspectRef); }
/** * Find a child by the name ({@link SType#getName()}) * @param parent the parent instance * @param childName the complete name of the child {@link SType#getName()} * @return the chield */ public static Optional<? extends SInstance> findChildByName(@Nonnull SInstance parent, @Nonnull String childName) { if(parent instanceof SIComposite) { SType<?> sType = parent.getDictionary().getType(childName); return ((SIComposite)parent).findDescendant(sType); } return Optional.empty(); }
/** Checks if the instance is in the same dictionary of scope. If not, throws a exception. */ static final void verifySameDictionary(@Nonnull SScope scope, @Nonnull SInstance instance) { if (scope.getDictionary() != instance.getDictionary()) { throw new SingularFormException( "O dicionário da instância " + instance + " não é o mesmo dicionário do tipo " + scope + ". Foram carregados em separado", instance); } }
@Override public final boolean hasAttributeValueDirectly(@Nonnull AtrRef<?, ?, ?> atr) { AttrInternalRef ref = getDictionary().getAttributeReferenceOrException(atr); return AttributeValuesManager.staticGetAttributeDirectly(attributes, ref) != null; }
private static boolean isType(@Nullable SInstance instance, @Nonnull SType<?> field) { return instance != null && instance.getDictionary() == field.getDictionary() && instance.isTypeOf(field); }
@Override public final <V> V getAttributeValue(@Nonnull String attributeFullName, @Nullable Class<V> resultClass) { return getAttributeValue(getDictionary().getAttributeReferenceOrException(attributeFullName), resultClass); }
/** Verifies if the SType of the SInstance is of the informed type. */ @Nonnull public AssertionsSInstance isTypeOf(@Nonnull Class<? extends SType<?>> expectedType) { return isTypeOf(getTarget().getDictionary().getType(expectedType)); }
/** * Calcula a view mais adequeada para instancia informada. Retorna * MView.DEFAULT, se não houver nenhum direcionamento específico e nesse * caso então cabe a cada gerador decidir como criar o componente na tela. */ public static SView resolve(SInstance instance) { return instance.getDictionary().getViewResolver().resolveInternal(instance); }
/** * Calcula a view mais adequeada para instancia informada. Retorna * MView.DEFAULT, se não houver nenhum direcionamento específico e nesse * caso então cabe a cada gerador decidir como criar o componente na tela. */ public static SView resolve(SInstance instance) { return instance.getDictionary().getViewResolver().resolveInternal(instance); }
@Nullable @Override public final <V> V getAttributeValue(@Nonnull AtrRef<?, ?, V> atr) { return getAttributeValue(getDictionary().getAttributeReferenceOrException(atr), atr.getValueClass()); }
final void setAttributeValueSavingForLatter(@Nonnull String attributeName, @Nullable String value) { AttrInternalRef ref = getDictionary().getAttribureRefereceOrCreateLazy(attributeName); getAttributesMap().setAttributeValue(ref, null, value); }
/** * USO INTERNO: Cria um nova lista de anotações em um novo SDocument, tendo como base as informações de definição * do documento informado. * Cria uma nova lista de anotações utilizando as configurações de registry do document passado por * parâmetro. Essa método tem por objetivo evitar que a nova lista criada fique sem os serviços locais e service * registry já configurados na lista original. * @param executeInitTypeSetup Se true, dispara as inicializações automáticas implementadas em * {@link SInstance#init()}. Usar como false quando a instância está sendo recuperada da persistência. Ver * {@link SDocumentFactory#createInstance(RefType, boolean)}. */ public static SIList<SIAnnotation> newAnnotationList(@Nonnull SDocument docRef, boolean executeInitTypeSetup) { Optional<RefType> rootRefType = docRef.getRootRefType(); if (rootRefType.isPresent()) { RefType refTypeAnnotation = rootRefType.get().createSubReference(STypeAnnotationList.class); SDocumentFactory documentFactory; RefSDocumentFactory refSDocumentFactory = docRef.getDocumentFactoryRef(); if (refSDocumentFactory != null) { documentFactory = refSDocumentFactory.get(); } else { documentFactory = SDocumentFactory.empty(); } return (SIList<SIAnnotation>) documentFactory.createInstance(refTypeAnnotation, executeInitTypeSetup); } return (SIList) docRef.getRoot().getDictionary().newInstance(STypeAnnotationList.class); }
/** * USO INTERNO: Cria um nova lista de anotações em um novo SDocument, tendo como base as informações de definição * do documento informado. * Cria uma nova lista de anotações utilizando as configurações de registry do document passado por * parâmetro. Essa método tem por objetivo evitar que a nova lista criada fique sem os serviços locais e service * registry já configurados na lista original. * @param executeInitTypeSetup Se true, dispara as inicializações automáticas implementadas em * {@link SInstance#init()}. Usar como false quando a instância está sendo recuperada da persistência. Ver * {@link SDocumentFactory#createInstance(RefType, boolean)}. */ public static SIList<SIAnnotation> newAnnotationList(@Nonnull SDocument docRef, boolean executeInitTypeSetup) { Optional<RefType> rootRefType = docRef.getRootRefType(); if (rootRefType.isPresent()) { RefType refTypeAnnotation = rootRefType.get().createSubReference(STypeAnnotationList.class); SDocumentFactory documentFactory; RefSDocumentFactory refSDocumentFactory = docRef.getDocumentFactoryRef(); if (refSDocumentFactory != null) { documentFactory = refSDocumentFactory.get(); } else { documentFactory = SDocumentFactory.empty(); } return (SIList<SIAnnotation>) documentFactory.createInstance(refTypeAnnotation, executeInitTypeSetup); } return docRef.getRoot().getDictionary().newInstance(STypeAnnotationList.class); }
SType<?> type = model.getObject().getDictionary().getType(col.getTypeName()); ColumnType columnType = new ColumnType(type.getName(), col.getCustomLabel(), col.getColumnSortName(), col.getDisplayValueFunction()); columnTypes.add(columnType);
/** * Verifica se a instância informada é do tipo atual, senão dispara exception. */ public void checkIfIsInstanceOf(SInstance instance) { if (getDictionary() != instance.getDictionary()) { throw new SingularFormException("O dicionário da instância " + instance + " não é o mesmo do tipo " + this + ". Foram carregados em separado", instance); } for (SType<?> current = instance.getType(); current != null; current = current.getSuperType()) { if (current == this) { return; } } throw new SingularFormException( "A instância " + instance + " é do tipo " + instance.getType() + ", mas era esperada ser do tipo " + this, instance); }