@Override public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) { final SimpleDateFormat format = new SimpleDateFormat(STypeTime.FORMAT); if (model.getObject().getValue() instanceof Date) { return format.format(model.getObject().getValue()); } return StringUtils.EMPTY; }
@Override public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) { final SimpleDateFormat format = new SimpleDateFormat(STypeDateTime.FORMAT); if (model.getObject().getValue() instanceof Date) { return format.format(model.getObject().getValue()); } return StringUtils.EMPTY; } }
public Object toRelationalColumn(SInstance fromInstance) { Object value = fromInstance.getValue(); if (value == null) { return null; } return Integer.valueOf(value.toString()); }
@Override public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) { final SInstance mi = model.getObject(); if ((mi != null) && (mi.getValue() != null)) { final BigDecimal value = (BigDecimal) mi.getValue(); return formatDecimal(value, true); } return StringUtils.EMPTY; }
@Override public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) { if ((model != null) && (model.getObject() != null)) { SInstance instance = model.getObject(); if (instance.getValue() instanceof Date) { Date dt = (Date) instance.getValue(); final SimpleDateFormat formatter = defaultDateFormat(); return formatter.format(dt); } } return StringUtils.EMPTY; }
public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) { if ((model != null) && (model.getObject() != null)) { SInstance instancia = model.getObject(); if (instancia.getValue() instanceof Date) { Date dt = (Date) instancia.getValue(); final SimpleDateFormat formattter = defaultDateFormat(); return formattter.format(dt); } } return StringUtils.EMPTY; }
@Override public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) { if ((model != null) && (model.getObject() != null)) { SInstance instancia = model.getObject(); if (instancia.getValue() instanceof YearMonth) { YearMonth ym = (YearMonth) instancia.getValue(); return String.format("%02d/%04d", ym.getMonthValue(), ym.getYear()); } } return StringUtils.EMPTY; } }
public Object toRelationalColumn(SInstance fromInstance) { Object value = fromInstance.getValue(); if (value == null) { return null; } return ((SIAttachment) fromInstance).getAttachmentRef(); }
@SuppressWarnings("unchecked") public default <V> List<V> listDescendantValues(SType<?> descendantType, Class<V> valueType) { return SInstances.listDescendants((SInstance) this, descendantType, node -> (V) node.getValue()); } public default Stream<SInstance> streamDescendants(boolean includeRoot) {
@Override @SuppressWarnings("unchecked") public T getObject() { return (T) getTarget().getValue(); }
@Override @SuppressWarnings("unchecked") public T getObject() { return (T) getTarget().getValue(); }
/** * Cria uma nova assertiva para o valor da instância, se a instância contiver um valor Date. Senão o valor for * diferente de null e não for Date, então dispara exception. */ public AbstractDateAssert<?> assertDateValue() { Object value = getTarget().getValue(); if (value instanceof Date || value == null) { return assertThat((Date) value); } throw new AssertionError(errorMsg("O Objeto da instancia atual não é do tipo Date")); }
public AbstractCharSequenceAssert<?, String> assertStringValue() { Object value = getTarget().getValue(); if (value instanceof String || value == null) { return assertThat((String) value); } throw new AssertionError(errorMsg("O Objeto da instancia atual não é do tipo String")); }
@Override public void validate(InstanceValidatable<SIComposite> v) { Set<Boolean> nullValues = v.getInstance().streamDescendants(false) .filter(it -> it.getType() instanceof STypeSimple<?, ?>) .map(it -> it.getValue() == null) .collect(toSet()); // os campos devem ser todos nulos ou todos preenchidos if (nullValues.size() != 1) v.error("Endereço incompleto"); } }
/** * Devolve o valor que deve ser repassadado para engine de javascript. As vezes, o valor não é o próprio wrapper. */ public Object getValueForEngine() { if (isSimpleType()) { return getInstance().getValue(); } return this; }
@Override public Serializable getObject() { SViewListByForm view = (SViewListByForm) ctx.getView(); if (view.getHeaderPath() != null) { return Optional.ofNullable(item.getModelObject().getValue(view.getHeaderPath())).orElse("").toString(); } else { return item.getModelObject().toStringDisplay(); } } };
@Override public void onAction(SInstanceAction action, ISupplier<SInstance> actionInstanceSupplier, Delegate delegate) { final SInstance formInstance = formDelegate.getFormInstance(); final SInstance fieldInstance = delegate.getInstanceRef().get(); final SIAnnotation annotationInstance = fieldInstance.asAtrAnnotation().annotation(); annotationInstance.setApproved(formInstance.getValue(EditAnotacaoRefType.APPROVED)); annotationInstance.setText(formInstance.getValue(EditAnotacaoRefType.JUSTIFICATION)); delegate.refreshFieldForInstance(fieldInstance); formDelegate.close(); } }
private Object getValue(String fieldPath) { if (fieldPath == null) { return getTarget().getValue(); } else if (getTarget() instanceof ICompositeInstance) { return ((ICompositeInstance) getTarget()).getValue(fieldPath); } throw new AssertionError(errorMsg("O tipo da instância não aceita leitura de path '" + fieldPath + "'")); }
private static void writeAttr(ContextArchive ctx, SIPersistenceAttribute attributeArchive, SInstance attribute) { attributeArchive.setAttrType(attribute.getType().getName()); attributeArchive.setAttrValue(attribute.getValue()); } //