#75 Added transaction base classes
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package de.rwu.easydrop.service.mapping;
|
||||
|
||||
import de.rwu.easydrop.api.dto.TransactionDTO;
|
||||
import de.rwu.easydrop.model.Transaction;
|
||||
|
||||
/**
|
||||
* Maps transaction DTOs and objects.
|
||||
*
|
||||
* @since 0.3.0
|
||||
*/
|
||||
public final class TransactionMapper {
|
||||
/**
|
||||
* Private constructor to prevent unwanted instantiation.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
private TransactionMapper() throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException("This is a mapping class, don't instantiate it.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Transaction object from a corresponding DTO.
|
||||
*
|
||||
* @param dto Transaction Data Transfer Object
|
||||
* @return Product
|
||||
*/
|
||||
public static Transaction mapTXFromDTO(final TransactionDTO dto) {
|
||||
Transaction tx = new Transaction();
|
||||
|
||||
tx.setOfferId(dto.getOfferId());
|
||||
tx.setVolume(dto.getVolume());
|
||||
tx.setEarnings(dto.getEarnings());
|
||||
tx.setTransactionTime(dto.getTransactionTime());
|
||||
|
||||
return tx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a ProductDTO object from a corresponding Product.
|
||||
*
|
||||
* @param tx Transaction
|
||||
* @return TransactionDTO
|
||||
*/
|
||||
public static TransactionDTO mapTXToDTO(final Transaction tx) {
|
||||
TransactionDTO dto = new TransactionDTO();
|
||||
|
||||
dto.setOfferId(tx.getOfferId());
|
||||
dto.setVolume(tx.getVolume());
|
||||
dto.setEarnings(tx.getEarnings());
|
||||
dto.setTransactionTime(tx.getTransactionTime());
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user