Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

fun sumOf(
first: CustomerAllocatedCapacity,
second: CustomerAllocatedCapacity
): List<CustomerAllocatedCapacity> {
...
}
interface CustomerAllocatedCapacity {
val id: CustomerAllocatedCapacityId
val allocationStartInstant: Instant
val allocationEndInstant: Instant
val quantity: EnergyQuantity
fun add(other: CustomerAllocatedCapacity): CustomerAllocatedCapacity
fun subtract(other: CustomerAllocatedCapacity): CustomerAllocatedCapacity
fun sum(values: List<QuantityOverDateRange>): List<QuantityOverDateRange> {
// ...
}
class CustomerAllocatedCapacity(
val id: CustomerAllocatedCapacityId,
val allocationStartInstant: Instant,
val allocationEndInstant: Instant,
val quantity: EnergyQuantity
) {
val allocationPeriod
get () = DateRange(allocationStartInstant, allocationEndInstant)
(id , contrat , parent)
[-----------100------------] (ca1 , cédant , )
[-------100---------] (ca2 , cédant , )
[-------200---------] (cos1, cédant , )
[-100-] (cos2, cédant , )
[--------200--------] (cc , customer1 => customer2, )
[--------100--------] ( , cessionnaire , ca1 )
[--------100--------] ( , cessionnaire , ca2 )
interface QuantityOverDateRange {
val dateRange: DateRange
val quantity: Quantity
val groupId: String?
fun startBefore(period: DateRange): Boolean
fun endAfter(period: DateRange): Boolean
data class SubtractionResult(
val remainingRanges: List<QuantityOverDateRange>,
val changes: List<Change>,
) {}
interface QuantityOverDateRange {
val dateRange: DateRange
val quantity: Quantity
val groupId: String?
fun subtract(subtrahend: QuantityOverDateRange): SubtractionResult
fun add(value: QuantityOverDateRange): List<QuantityOverDateRange>
}
interface QuantityOverDateRange {
val dateRange: DateRange
val quantity: Quantity
val groupId: String?
}
@mohamed-gara
mohamed-gara / Person.java
Created September 25, 2021 12:02
Person class with Lombok
@Value
@Builder
public class Person {
String firstName;
String lastName;
Integer age;
}