More extra data
This commit is contained in:
parent
625b023733
commit
22064c8c7c
5 changed files with 51 additions and 5 deletions
|
|
@ -21,6 +21,8 @@ public final class ExtraBuilder
|
|||
|
||||
/**
|
||||
* Create an empty builder to create an {@link ExtraObject}.
|
||||
* It will be already pointing to the root object and values can be added
|
||||
* to it.
|
||||
*/
|
||||
public ExtraBuilder() {
|
||||
this.path = new ArrayList<ExtraData>();
|
||||
|
|
@ -198,6 +200,28 @@ public final class ExtraBuilder
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a value to the current array.
|
||||
* @param value The value to add.
|
||||
* @throws IllegalStateException When not currently building an array.
|
||||
* @throws IllegalArgumentException When not building an array of Integers.
|
||||
*/
|
||||
public void add(int value) throws IllegalStateException {
|
||||
this.checkCurrentArray();
|
||||
this.currentArray.addValue(new ExtraInt(this.currentArray.size(), value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a value to the current object.
|
||||
* @param field The name of the field that holds the value.
|
||||
* @param value The value to add.
|
||||
* @throws IllegalStateException When not currently building an object.
|
||||
*/
|
||||
public void add(String field, int value) throws IllegalStateException {
|
||||
this.checkCurrentObject();
|
||||
this.currentObject.setValue(new ExtraInt(field, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop building extra data and get the final object.
|
||||
* Once close is called, no other operation can be done.
|
||||
|
|
|
|||
|
|
@ -8,5 +8,9 @@
|
|||
* values. All values of {@link org.pasteque.coreutil.extra.ExtraData}
|
||||
* implementations are non-null. When the value is null, use an explicit
|
||||
* {@link org.pasteque.coreutil.extra.ExtraNull}.</p>
|
||||
* <p>Extra objects will be found only in the major classes and their
|
||||
* associated DTO from coreutil. Other packages will have the semantic values
|
||||
* instead and convert them to extra data only when creating a major version
|
||||
* of itself through transition interfaces.</p>
|
||||
*/
|
||||
package org.pasteque.coreutil.extra;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package org.pasteque.major.domain;
|
||||
|
||||
import org.pasteque.coreutil.datatransfer.dto.CashRegisterDTO;
|
||||
import org.pasteque.coreutil.extra.ExtraObject;
|
||||
|
||||
/**
|
||||
* <p>Model for a cash register. Tickets are associated to a cash register
|
||||
|
|
@ -14,6 +15,8 @@ public class MajorCashRegister
|
|||
private String label;
|
||||
/** {@see getNextTicketNumber()} */
|
||||
private int nextTicketNumber;
|
||||
/** See {@link getExtra()}. */
|
||||
private ExtraObject extra;
|
||||
|
||||
/**
|
||||
* Create from all fields.
|
||||
|
|
@ -21,24 +24,28 @@ public class MajorCashRegister
|
|||
* @param label See {@link getLabel()}.
|
||||
* @param nextTicketNumber The number to assign to the next ticket
|
||||
* from this cash register.
|
||||
* @param extra See {@link getExtra()}.
|
||||
*/
|
||||
public MajorCashRegister(
|
||||
String reference,
|
||||
String label,
|
||||
int nextTicketNumber) {
|
||||
int nextTicketNumber,
|
||||
ExtraObject extra) {
|
||||
this.reference = reference;
|
||||
this.label = label;
|
||||
this.nextTicketNumber = nextTicketNumber;
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create from a DTO. All data are copied to break references.
|
||||
* Create from a DTO.
|
||||
* @param dto The DTO to convert.
|
||||
*/
|
||||
public MajorCashRegister(CashRegisterDTO dto) {
|
||||
this.reference = new String(dto.getReference());
|
||||
this.label = new String(dto.getLabel());
|
||||
this.reference = dto.getReference();
|
||||
this.label = dto.getLabel();
|
||||
this.nextTicketNumber = dto.getNextTicketNumber();
|
||||
this.extra = dto.getExtra();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,4 +84,12 @@ public class MajorCashRegister
|
|||
/* package */ final void revertNextTicketNumber() {
|
||||
this.nextTicketNumber--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all other data.
|
||||
* @return The root object of extra data.
|
||||
*/
|
||||
public final ExtraObject getExtra() {
|
||||
return this.extra;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public final class MajorOrder implements OrderTransition
|
|||
private final Price2 finalTaxedPrice;
|
||||
private final ImmutableList<MajorLine> lines;
|
||||
private final Discount discount;
|
||||
/** See {@link getExtra()}. */
|
||||
private final ExtraObject extra;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.pasteque.major.domain;
|
|||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.pasteque.coreutil.extra.ExtraObject;
|
||||
import org.pasteque.coreutil.constants.FiscalTicketType;
|
||||
import org.pasteque.coreutil.datatransfer.dto.FiscalTicketDTO;
|
||||
|
||||
|
|
@ -23,7 +24,8 @@ public final class MajorZTicket
|
|||
MajorCashSession session,
|
||||
Date closeDate,
|
||||
int closeType,
|
||||
List<Movement> endAmounts) {
|
||||
List<Movement> endAmounts,
|
||||
ExtraObject extra) {
|
||||
// TODO: not implemented
|
||||
throw new UnsupportedOperationException("Not implemented yet");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue