001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2022, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.core.model;
015
016import java.util.Objects;
017
018public class TimestampModel extends NamedModel {
019
020    private static final long serialVersionUID = 2096655273673863306L;
021
022    public static final String CONTEXT_BIRTH = "contextBirth";
023
024    String datePattern;
025    String timeReference;
026    String scopeStr;
027
028    @Override
029    protected TimestampModel makeNewInstance() {
030        return new TimestampModel();
031    }
032    
033    @Override
034    protected void mirror(Model that) {
035        TimestampModel actual = (TimestampModel) that;
036        super.mirror(actual);
037        this.datePattern = actual.datePattern;
038        this.timeReference = actual.timeReference;
039        this.scopeStr = actual.scopeStr;
040    }
041    
042    public String getKey() {
043        return getName();
044    }
045
046    public void setKey(String key) {
047        this.setName(key);
048    }
049
050    public String getDatePattern() {
051        return datePattern;
052    }
053
054    public void setDatePattern(String datePattern) {
055        this.datePattern = datePattern;
056    }
057
058    public String getTimeReference() {
059        return timeReference;
060    }
061
062    public void setTimeReference(String timeReference) {
063        this.timeReference = timeReference;
064    }
065
066    public String getScopeStr() {
067        return scopeStr;
068    }
069
070    public void setScopeStr(String scopeStr) {
071        this.scopeStr = scopeStr;
072    }
073
074    @Override
075    public int hashCode() {
076        final int prime = 31;
077        int result = super.hashCode();
078        result = prime * result + Objects.hash(datePattern, scopeStr, timeReference);
079        return result;
080    }
081
082    @Override
083    public boolean equals(Object obj) {
084        if (this == obj)
085            return true;
086        if (!super.equals(obj))
087            return false;
088        if (getClass() != obj.getClass())
089            return false;
090        TimestampModel other = (TimestampModel) obj;
091        return Objects.equals(datePattern, other.datePattern) && Objects.equals(scopeStr, other.scopeStr)
092                && Objects.equals(timeReference, other.timeReference);
093    }
094
095    
096}