/** * Criar uma nova instância do tipo atual e executa os códigos de inicialização dos tipos * se existirem (ver {@link #withInitListener(IConsumer)}}). */ public final I newInstance() { return newInstance(true); }
/** * Cria uma nova instância pertencente ao documento informado. */ I newInstance(SDocument owner) { return newInstance(this, owner); }
/** * Cria uma nova instância pertencente ao documento informado. */ I newInstance(SDocument owner) { return newInstance(this, owner); }
/** @see {@link SType#newInstance(boolean, SDocument)} */ public SInstance newInstance(@Nonnull SType target, boolean executeInstanceInitListeners,@Nonnull SDocument owner) { return target.newInstance(executeInstanceInitListeners, owner); }
/** * Criar uma nova instância do tipo atual e executa os códigos de inicialização dos tipos * se existirem (ver {@link #withInitListener(IConsumer)}}). */ public final I newInstance() { return newInstance(true, new SDocument()); }
/** * Cria uma instância não passível de serialização para do tipo com o * conteúdo persistido no XML informado. */ public static <T extends SInstance> T fromXML(SType<T> tipo, MElement xml) { return fromXMLInterno(tipo.newInstance(), xml); }
/** * Cria uma instância não passível de serialização para do tipo com o * conteúdo persistido no XML informado. */ @Nonnull public static <T extends SInstance> T fromXML(@Nonnull SType<T> type, @Nullable MElement xml) { return fromXMLInterno(type.newInstance(), xml); }
/** * Cria uma instância não passível de serialização para do tipo com o * conteúdo persistido no XML informado. */ @Nonnull public static <T extends SInstance> T fromXML(@Nonnull SType<T> type, @Nullable String xmlString) { return fromXMLInterno(type.newInstance(), parseXml(xmlString)); }
/** * Cria uma instância não passível de serialização para do tipo com o * conteúdo persistido no XML informado. */ public static <T extends SInstance> T fromXML(SType<T> tipo, String xmlString) { return fromXMLInterno(tipo.newInstance(), parseXml(xmlString)); }
@SuppressWarnings("unchecked") public <ST extends SType<?>> List<SInstance> getChoices(IFunction<T, ST> typeFinder) { SInstance subInstance = resolveTypeFinderInstance(typeFinder); ST subtype = (ST) subInstance.getType(); Component component = getComponentForSType(subtype); SInstanceConverter converter = subInstance.asAtrProvider().getConverter(); return (List<SInstance>) ((AbstractChoice) component).getChoices().stream().map(serializable -> { SInstance choiceInstance = subtype.newInstance(); converter.fillInstance(choiceInstance, (Serializable) serializable); return choiceInstance; }).collect(Collectors.toList()); }
@Nonnull private E addNewInternal(boolean atEnd, int index) { E instance = getElementsType().newInstance(getDocument()); addInternal(instance, atEnd, index); instance.init(); return instance; }
public E addNewAt(int index) { E instance = getElementsType().newInstance(getDocument()); return addInternal(instance, false, index); }
public E addNew() { E instance = getElementsType().newInstance(getDocument()); return addInternal(instance, true, -1); }
final SInstance newAttributeInstanceFor(SType<?> typeToBeAppliedAttribute) { checkIfIsAttribute(); SInstance attrInstance; if (attrInternalRef.isSelfReference()) { attrInstance = typeToBeAppliedAttribute.newInstance(getDictionary().getInternalDicionaryDocument()); } else { attrInstance = newInstance(getDictionary().getInternalDicionaryDocument()); } attrInstance.setAsAttribute(attrInternalRef, typeToBeAppliedAttribute); return attrInstance; }
final SInstance newAttributeInstanceFor(SType<?> typeToBeAppliedAttribute) { checkIfIsAttribute(); SInstance attrInstance; if (attributeDefinitionInfo.isSelfReference()) { attrInstance = typeToBeAppliedAttribute.newInstance(getDictionary().getInternalDicionaryDocument()); } else { attrInstance = newInstance(getDictionary().getInternalDicionaryDocument()); } attrInstance.setAsAttribute(getName(), this); return attrInstance; }
@Override @Nonnull protected SInstance createNewAttribute(@Nonnull AttrInternalRef ref) { SType<?> attributeType = AttributeValuesManagerForSType.getAttributeDefinedHierarchy(getOwner().getType(), ref); SInstance instanceAtr = attributeType.newInstance(getOwner().getDocument()); instanceAtr.setAsAttribute(ref, getOwner()); return instanceAtr; }
@Nonnull private E addElementInternal(@Nonnull E instance, boolean atEnd, int index) { if (instance.getDocument() == getDocument()) { return addInternal(instance, atEnd, index); } else { E copy = getElementsType().newInstance(getDocument()); Value.copyValues(instance, copy); return addInternal(copy, atEnd, index); } }
/** * 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 SInstance createField(int fieldIndex) { SType<?> fieldType = getType().getField(fieldIndex); SInstance instance = fieldType.newInstance(getDocument()); if (fields == null) { fields = new FieldMapOfRecordInstance(getType().size()); } fields.set(fieldIndex, instance); instance.setParent(this); return instance; }
private SInstance createField(int fieldIndex) { SType<?> fieldType = getType().getField(fieldIndex); SInstance instance = fieldType.newInstance(getDocument()); if (fields == null) { fields = new FieldMapOfRecordInstance(getType().size()); } fields.set(fieldIndex, instance); instance.setParent(this); return instance; }