/** * Recupera o tipo, já carregado no dicionário, da classe informada. Senão estiver carregado ainda, busca carregá-lo * e as definições do pacote a que pertence. Senão encontrar no dicionário e nem conseguir encontrar para carregar, * então dispara Exception. É o mesmo que chamar {@link SDictionary#getType(Class)}. */ @Nonnull public <T extends SType<?>> T getType(@Nonnull Class<T> typeClass) { return dictionary.getType(typeClass); }
@SuppressWarnings("unchecked") final void resolvSuperType(SDictionary dictionary) { if (superType == null && getClass() != SType.class) { Class<SType> c = (Class<SType>) getClass().getSuperclass(); if (c != null) { this.superType = dictionary.getType(c); } } }
@SuppressWarnings("unchecked") final void resolveSuperType(SDictionary dictionary) { if (superType == null && getClass() != SType.class) { Class<? extends SType> c = getClass(); do { c = (Class<SType>) c.getSuperclass(); } while (Modifier.isAbstract(c.getModifiers())); superType = dictionary.getType(c); } }
@Override @Nonnull protected SType<?> retrieve() { return SDictionary.create().getType(typeClass); } };
/** * Cria o tipo e dicionário necessário para o tipo da estrutura de dados de * persistência da definição. */ private static STypePersistenceArchive createTypePersistence() { return SDictionary.create().getType(STypePersistenceArchive.class); }
/** * Recupera o tipo, já carregado no dicionário, da classe informada. Senão estiver carregado ainda, busca carregá-lo * e as definições do pacote a que pertence. Senão encontrar no dicionário e nem conseguir encontrar para carregar, * então dispara Exception. É o mesmo que chamar {@link SDictionary#getType(Class)}. * * @return Nunca Null. */ public <T extends SType<?>> T getType(Class<T> typeClass) { return getDictionary().getType(typeClass); }
@Override @Nonnull protected SType<?> retrieve() { return RefType.this.get().getDictionary().getType(typeClass); } };
/** 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)); }
@SuppressWarnings("unchecked") static <I extends SInstance> SIList<I> of(SType<I> elementsType) { SDictionary dictionary = elementsType.getDictionary(); STypeList<?, ?> type = dictionary.getType(STypeList.class); SIList<I> list = (SIList<I>) type.newInstance(); list.elementsType = elementsType; return list; }
@Override protected void onLoadType(TypeBuilder tb) { setElementsType(getDictionary().getType(STypeString.class)); } }
@Override protected void onLoadType(TypeBuilder tb) { setElementsType(getDictionary().getType(STypeAnnotation.class)); } }
private void prepareDefaultImports(SDictionary dictionary) { for (SType<?> type : dictionary.getType(SType.class).getPackage().getLocalTypes()) { imports.put(type.getNameSimple(), type.getName()); } }
/** * Verifica se o tipo e seu tipos internos (se existirem) extendem corretamente o tipo informado. Faz uma analise * recursiva para os subtipos. */ public AssertionsSType isExtensionCorrect(Class<? extends SType> typeClass) { return isExtensionCorrect(getTarget().getDictionary().getType(typeClass)); }
/** * This method create a predicate for verify if the instance have a element with the sortableProperty. * <p>Note: This verify with the name of the Stype. * * @return Predicate verify if have a Stype with the <code>sortableProperty</code> for a SIntance. */ private Predicate<SInstance> isCurrentSortInstance() { return i -> i.getType().isTypeOf(i.getType().getDictionary().getType(sortableProperty)) || SFormUtil.findChildByName(i, sortableProperty).isPresent(); }
/** * Verifica se o tipo encontrado no caminho indicado é uma extensão direta do tipo informado. Para ser considerado * uma extensão direta, deverá ser da mesma classe do tipo (não pode ser derivado) e seu super tipo {@link * SType#getSuperType()} deve ser igual o tipo registrado no dicionário. */ public AssertionsSType isDirectExtensionOf(Class<? extends SType<?>> typeClass, String fieldPath) { SType<?> expectedSuperType = getTarget().getDictionary().getType(typeClass); if (fieldPath != null) { expectedSuperType = expectedSuperType.getLocalType(fieldPath); } return isDirectExtensionOf(expectedSuperType); }
public AtrSQL foreignColumn(String column, String keyColumns, Class<? extends SType<?>> typeClass) { String tableName = RelationalSQL.tableOpt(RelationalSQL.tableContext(getType())).orElse(null); RelationalFK foreignKey = new RelationalFK(tableName, keyColumns, getDictionary().getType(typeClass)); return foreignColumn(column, foreignKey); }
public SType<?> tableContext(SType<?> type) { SType<?> result = type; while (table(result) == null && !result.getParentScope().equals(result.getPackage())) { result = result.getDictionary().getType(result.getParentScope().getName()); } return result; }
private void add(Class<? extends SType<?>> type) { String typeName = SFormUtil.getTypeName(type); add(typeName, () -> { SDictionary d = SDictionary.create(); d.loadPackage(SFormUtil.getTypePackage(type)); return d.getType(type); }); }
/** * Cria um atributo temporariamente sem a sua definição de tipo definitiva. Em quanto isso, será considerado como * String. Provavelmente utilizado para guardar valores em quanto o real registro do atributo não é feito no * dicionário. */ @Nonnull protected final SInstance createTemporaryAttribute() { SType<?> attrType = getOwner().getDictionary().getType(STypeString.class); SInstance attr = attrType.newInstance(getOwner().getDictionary().getInternalDicionaryDocument()); attr.setAttributeShouldMigrate(); return attr; }
private void add(Class<? extends SType<?>> type) { String typeName = RequirementUtil.getTypeName(type); add(typeName, () -> { SDictionary d = SDictionary.create(); d.loadPackage(SFormUtil.getTypePackage(type)); return d.getType(type); }); }