/** * From a {@link IDescribableBean} to another {@link IDescribableBean} bean copy. * * @param <T> * Bean type. * @param from * the {@link IDescribableBean} source. Must not be null. * @param to * the target {@link IDescribableBean} to fill. Must not be null. */ public static <T extends Serializable> void copy(final IDescribableBean<T> from, final IDescribableBean<T> to) { NamedBean.copy(from, to); to.setDescription(from.getDescription()); }
/** * Copy data from the memory object to the cache entity. */ private <T extends CacheContainer> T fillCacheContainer(final ContainerOrg container, final T entity) { DescribedBean.copy(container, entity); return entity; }
@Override public Date deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { if (parser.getCurrentToken() == JsonToken.VALUE_NUMBER_INT) { final Calendar newCalendar = DateUtils.newCalendar(); newCalendar.setTimeInMillis(parser.getLongValue()); return newCalendar.getTime(); } return _parseDate(parser, context); }
/** * Pattern and data constructor. * * @param pattern * the pattern used to parse the input.. * @param data * the context data or another {@link Processor} instance. */ public ParseDateProcessor(final String pattern, final Object data) { super(data); this.format = FastDateFormat.getInstance(pattern, DateUtils.getApplicationTimeZone()); }
/** * From a {@link IDescribableBean} to a new {@link DescribedBean} bean clone. * * @param <T> * Bean type. * @param from * the {@link IDescribableBean} source. May be null. * @return <code>null</code> or new {@link DescribedBean} instance copied from the source. */ public static <T extends Serializable> DescribedBean<T> clone(final IDescribableBean<T> from) { if (from == null) { return null; } final DescribedBean<T> bean = new DescribedBean<>(); copy(from, bean); return bean; }
/** * {@link Node} JPA to VO object transformer without refined information. * * @param entity * Source entity. * @return The corresponding VO object without recursive redefined reference. */ public static NodeVo toVoLight(final Node entity) { final NodeVo vo = new NodeVo(); NamedBean.copy(entity, vo); vo.setMode(entity.getMode()); vo.setUiClasses(entity.getUiClasses()); return vo; }
/** * Define the modifiable state of a valued object. * * @param <T> * Bean type. * @param from * The source object to copy to current one. */ public <T extends Auditable<U, K, Date>> void copyAuditData(final T from) { copyAuditData(from, Function.identity()); }
@Override protected void loadProperties(final Properties props) throws IOException { super.setLocations(locations); setIgnoreUnresolvablePlaceholders(true); // Load the properties super.loadProperties(props); // Save the global properties setGlobalProperties(props); }
@Override @Autowired public void setApplicationContext(final ApplicationContext applicationContext) { setSharedApplicationContext(applicationContext); }
@Override protected String resolveSystemProperty(final String key) { return convertPropertyValue(super.resolveSystemProperty(key)); } }
/** * Update the application time zone. * * @param id * The new {@link TimeZone} identifier. */ @PUT @Path("timezone/application") public void setApplicationTimeZone(final String id) { DateUtils.setApplicationTimeZone(TimeZone.getTimeZone(id)); }
@Override public LocalDate fromString(final String value) { if (value == null) { return null; } return Instant.ofEpochMilli(Long.parseLong(value)).atZone(DateUtils.getApplicationTimeZone().toZoneId()).toLocalDate(); }
/** * /** Converter from {@link ProjectEditionVo} to {@link Project} */ private static Project toEntity(final ProjectEditionVo vo) { final Project entity = new Project(); // map project DescribedBean.copy(vo, entity); entity.setPkey(vo.getPkey()); entity.setTeamLeader(vo.getTeamLeader()); return entity; }
@Override public void serialize(final INamableBean<?> date, final JsonGenerator generator, final SerializerProvider provider) throws IOException { generator.writeString(date.getName()); }
@Override public String toString(final Date value) { return String.valueOf(value.toInstant().atZone(DateUtils.getApplicationTimeZone().toZoneId()).toInstant().toEpochMilli()); } }
/** * Write headers. */ private void writeNodeHeaders(final Writer writer) throws IOException { // Iterate over audited nodes for (final INamableBean<String> node : computations.getNodes()) { writer.write(";"); writer.write(node.getName()); } }
@Override public LocalDate deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { if (parser.getCurrentToken() == JsonToken.VALUE_NUMBER_INT) { return Instant.ofEpochMilli(parser.getLongValue()).atZone(DateUtils.getApplicationTimeZone().toZoneId()).toLocalDate(); } return null; }
@Override public LocalDateTime deserialize(final JsonParser parser, final DeserializationContext context) throws IOException { if (parser.getCurrentToken() == JsonToken.VALUE_NUMBER_INT) { return Instant.ofEpochMilli(parser.getLongValue()).atZone(DateUtils.getApplicationTimeZone().toZoneId()).toLocalDateTime(); } return null; }