All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javers.core.JaversCoreProperties Maven / Gradle / Ivy

There is a newer version: 7.6.2
Show newest version
package org.javers.core;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public abstract class JaversCoreProperties {
    private String algorithm = "simple";
    private String commitIdGenerator = "synchronized_sequence";
    private String mappingStyle = "field";
    private boolean newObjectSnapshot = false;
    private boolean prettyPrint = true;
    private boolean typeSafeValues = false;
    private String packagesToScan = "";
    private PrettyPrintDateFormats prettyPrintDateFormats = new PrettyPrintDateFormats();

    public String getAlgorithm() {
        return algorithm;
    }

    public String getCommitIdGenerator() {
        return commitIdGenerator;
    }

    public String getMappingStyle() {
        return mappingStyle;
    }

    public boolean isNewObjectSnapshot() {
        return newObjectSnapshot;
    }

    public boolean isPrettyPrint() {
        return prettyPrint;
    }

    public boolean isTypeSafeValues() {
        return typeSafeValues;
    }

    public String getPackagesToScan() {
        return packagesToScan;
    }

    public void setAlgorithm(String algorithm) {
        this.algorithm = algorithm;
    }

    public void setCommitIdGenerator(String commitIdGenerator) {
        this.commitIdGenerator = commitIdGenerator;
    }

    public void setMappingStyle(String mappingStyle) {
        this.mappingStyle = mappingStyle;
    }

    public void setNewObjectSnapshot(boolean newObjectSnapshot) {
        this.newObjectSnapshot = newObjectSnapshot;
    }

    public void setPrettyPrint(boolean prettyPrint) {
        this.prettyPrint = prettyPrint;
    }

    public void setTypeSafeValues(boolean typeSafeValues) {
        this.typeSafeValues = typeSafeValues;
    }

    public void setPackagesToScan(String packagesToScan) {
        this.packagesToScan = packagesToScan;
    }

    public PrettyPrintDateFormats getPrettyPrintDateFormats() {
        return prettyPrintDateFormats;
    }

    public static class PrettyPrintDateFormats {
        private Map, String> formats = new HashMap<>();

        private static final String DEFAULT_DATE_FORMAT = "dd MMM yyyy";
        private static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";

        public PrettyPrintDateFormats() {
            setLocalDateTime(DEFAULT_DATE_FORMAT + ", " + DEFAULT_TIME_FORMAT);
            setZonedDateTime(DEFAULT_DATE_FORMAT + ", " + DEFAULT_TIME_FORMAT+"Z");
            setLocalDate(DEFAULT_DATE_FORMAT);
            setLocalTime(DEFAULT_TIME_FORMAT);
        }

        public void registerFormat(Class forType, String format) {
            formats.put(forType, format);
        }

        public void setLocalDateTime(String localDateTime) {
            registerFormat(LocalDateTime.class, localDateTime);
        }

        public void setZonedDateTime(String zonedDateTime) {
            registerFormat(ZonedDateTime.class, zonedDateTime);
        }

        public void setLocalDate(String localDate) {
            registerFormat(LocalDate.class, localDate);
        }

        public void setLocalTime(String localTime) {
            registerFormat(LocalTime.class, localTime);
        }

        public String getLocalDateTime() {
            return formats.get(LocalDateTime.class);
        }

        public String getZonedDateTime() {
            return formats.get(ZonedDateTime.class);
        }

        public String getLocalDate() {
            return formats.get(LocalDate.class);
        }

        public String getLocalTime() {
            return formats.get(LocalTime.class);
        }

        public Map, String> getFormats() {
            return Collections.unmodifiableMap(formats);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy