package org.synyx.urlaubsverwaltung.period;

import java.math.BigDecimal;

public enum DayLength {

    FULL(BigDecimal.ONE),
    MORNING(new BigDecimal("0.5")),
    NOON(new BigDecimal("0.5")),
    ZERO(BigDecimal.ZERO);

    private final BigDecimal duration;

    DayLength(BigDecimal duration) {
        this.duration = duration;
    }

    public BigDecimal getDuration() {
        return this.duration;
    }

    /**
     * Pairs of enum members can be added to get a full day.
     *
     * @return the matching enum member which represents the rest of the day.
     */
    public DayLength getInverse() {
        switch (this) {
            case FULL:
                return ZERO;
            case MORNING:
                return NOON;
            case NOON:
                return MORNING;
            case ZERO:
                return FULL;
        }

        return null;
    }

    public boolean isHalfDay() { return duration.equals(MORNING.duration); }
}

@@ -116,16 +116,23 @@
 imal.ONE
+, false
 ),%0A    M
@@ -155,24 +155,30 @@
 cimal(%220.5%22)
+, true
 ),%0A    NOON(
@@ -198,16 +198,22 @@
 l(%220.5%22)
+, true
 ),%0A    Z
@@ -231,16 +231,23 @@
 mal.ZERO
+, false
 );%0A%0A    
@@ -280,16 +280,53 @@
 uration;
+%0A    private final boolean isHalfDay;
 %0A%0A    Da
@@ -352,16 +352,35 @@
 duration
+, boolean isHalfDay
 ) %7B%0A    
@@ -401,32 +401,68 @@
 ion = duration;%0A
+        this.isHalfDay = isHalfDay;%0A
     %7D%0A%0A    publi
@@ -1046,41 +1046,17 @@
 urn 
-duration.equals(MORNING.duration)
+isHalfDay
 ; %7D%0A

use static information for DayLength halfDay